在Perl中重定向时,如何使用POST发送值? [英] How do I send values with POST when redirecting in Perl?

查看:82
本文介绍了在Perl中重定向时,如何使用POST发送值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个值,一个是名称,另一个是密码,如果用户输入正确的组合,我希望将其传递给另一个页面。如果用户知道,我可以通过在查询字符串中包括以下值来重定向:

I have two values one for name and another for password that I would like to pass to another page if the user entered the right combination. If the user did I know that I can redirect by including the values in the query string like:

$cgi->redirect('http:someotherpage.com?username=$username&password=$password');

但这使用的是GET请求,有没有一种方法可以使用POST或在Perl中进行重定向时,还有另一种方法来传递值吗?我知道JSP有一个称为RequestDispatcher的方法,如果POST不可用,在Perl中是否有类似的东西?

but that is using a GET request, is there a way to do the same thing using a POST or is there another way to pass on the values when redirecting in Perl? I know that JSP has a method called RequestDispatcher is there something like that in Perl if the POST is not available?

编辑:我发现此链接 CGI应用程序分发较早,但这有点技术问题我不知道这是否是适合该工作的工具。

I found this link CGI Application Dispatch earlier but it's a little technical so I don't know if this is the right tool for the job.

编辑:我正在使用CGI.pm

I'm using CGI.pm

推荐答案

进行HTTP重定向时,您只能提供新目标的URL。这意味着,无法为POST请求指定任何数据,因为它们不在URL内。

When doing a HTTP redirect you can only give the URL of the new target. This means, there is no way to specify any data for the POST request, because they are outside the URL.

据我了解,JSP的RequestDispatcher不会发送HTTP重定向响应,但在JSP应用程序内部内部转发当前请求。这相当于让您的CGI脚本仅将当前请求分派到同一服务器上的另一个脚本,而无需通过浏览器进行重定向。详细信息如何执行将取决于您使用的框架(例如Dancer,Mojolicious,Catalyst ...或纯CGI.pm)

From my understanding the RequestDispatcher from JSP does not send a HTTP redirect response, but forwards the current request internally inside the JSP application. This would be comparable to let your CGI script just dispatch the current request to another script on the same server, without doing a redirect through the browser. Details how to do this would depend on the framework you use (e.g. Dancer, Mojolicious, Catalyst ... or plain CGI.pm)

这篇关于在Perl中重定向时,如何使用POST发送值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆