【问题标题】:Perl Mojolicious IIS routes going to POST methodPerl Mojolicious IIS 路由到 POST 方法
【发布时间】:2017-06-28 19:32:21
【问题描述】:

我们开始吧,我有一个 Mojolicious 应用程序,它在 morbo 服务器上运行时可以工作。当我在 IIS 中运行它时,它似乎可以工作,但是当您提交任何表单时,就像 IIS 不确定哪个路由是 GET 或 POST 方法。

所以目前我的路线看起来像

my $authorized = $r->under('/conditions_form')->to('Account#is_logged_in');
  $authorized->get('/')->name('beach_conditions_form')->to('form#show_beach_conditions_form');
  $authorized->post('/')->name('submit_conditions')->to('form#submit_beach_conditions');

当我的表单完成并提交后,它应该像这样重定向回表单

$self->redirect_to('beach_conditions_form');

这是我得到错误的时候! 错误类似于

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "[Wed Jun 28 15:26:22 2017] [debug] Reading configuration file "D:\inetpub\wwwroot\beach_conditions\beach_conditions.conf" [Wed Jun 28 15:26:22 2017] [debug] POST "/conditions_form" [Wed Jun 28 15:26:22 2017] [debug] Routing to controller "BeachConditions::Controller::Account" and action "is_logged_in" [Wed Jun 28 15:26:22 2017] [debug] Routing to controller "BeachConditions::Controller::Form" and action "submit_beach_conditions" [Wed Jun 28 15:26:22 2017] [error] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'OBS_DT', table 'BeachSafety.dbo.BEACH_CONDITIONS'; column does not allow nulls. INSERT fails. (SQL-23000) [state was 23000 now 01000] [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated. (SQL-01000) [for Statement "INSERT INTO BEACH_CONDITIONS ( beach_current, flag_color, note, obs_dt, obs_loc, rip_current_risk, water_temp, wave_height, wave_type, weather, wind_direction, wind_speed) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) SELECT SCOPE_IDENTITY()" with ParamValues: 1=undef, 2=undef, 3=undef, 4=undef, 5=undef, 6=undef, 7=undef, 8=undef, 9=undef, 10=undef, 11=undef, 12=undef] 

对我来说,这意味着它只是跳过了 GET 方法并直接进入 POST....

如果我硬编码路径,一切都很好(但一切都不好,因为它是硬编码的......)。

这行得通..

$self->redirect_to('http://server/beach_conditions/beach_conditions.pl/conditions_form');

我找到了这个,但没有太大帮助。

https://groups.google.com/forum/#!topic/mojolicious/IPJopdGCdKQ

感谢您提供任何信息。

【问题讨论】:

  • 您的 IIS 看到的东西不是标头。它正在读取日志输出,它应该转到 STDERR 并认为这是响应。您是如何将 Mojo 应用程序连接到 IIS 的?它是通过 FCGI 在 hypnotoad 上运行的吗?它在那条消息中谈到了CGI。如果那是真正的 CGI,它的效率会非常低,因为它需要为每个请求编译整个应用程序。我不认为你想要那个。
  • 啊,好吧,所以我错过了一块。我只是在运行启动脚本,就像在 morbo 中一样。我打开了 FastCGI,但它导致了错误,这对我来说很奇怪。所以目前是的,我现在只是在运行 CGI。我得研究一下这个“催眠蟾蜍”。谢谢!
  • 好吧,我有点困惑。 Hypnotoad 是在服务器上,比如 morbo 吗?所以你在服务器上运行一个服务器?对我来说似乎很奇怪,但我会试一试,看看会发生什么。
  • 是的,它是生产服务器。我认为您可以使用 FCGI 在 iis 后面运行它。但也许也完全没有 iis。你特别需要那个吗?用于提供文件或其他什么?
  • 好的,经过一番研究,代理服务器似乎是我所追求的。配置 IIS 以查看 Mojolicious 的守护程序服务器。我相当确定这是解决方案。我一试就会回来。

标签: perl iis routes mojolicious mojolicious-lite


【解决方案1】:

好的,@simbabque 是对的,您可以完全独立于 IIS 进行托管。

我刚刚制作了类似的启动脚本

Mojolicious::Commands->start_app('BeachConditions', 'daemon', '-l', 'http://*:8080');

现在它可以访问了,您只需运行启动脚本。

这让我想到了一个我将发布的新问题。 那么如何运行多个应用程序呢?

【讨论】:

  • 我觉得刚才的其他问题不用删。事实上,经过编辑的标题,它是副本的一个很好的替代品。我建议您取消删除它,以便其他面临与 Mojo 相关的相同问题的人可以找到它和重复的目标。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-02
  • 2020-06-28
  • 2016-06-28
  • 1970-01-01
相关资源
最近更新 更多