【问题标题】:Domain forwarding causes a POST http request being interpreted as GET?域转发导致 POST http 请求被解释为 GET?
【发布时间】:2017-12-15 18:15:07
【问题描述】:

我有一个包含表单提交的 html 页面:

<form name="pc_request_form" action="https://coupon-liquibil.rhcloud.com/RequestPointCard" method="POST">

其中https://coupon-liquibil.rhcloud.com 是托管应用程序的 Openshift 提供的 url。这很好用。

现在,我想使用自己的“webcoupon.us”作为应用程序的域,所以我在域注册商(Google)处设置了域转发:

http://webcoupon.us **to** https://coupon-liquibil.rhcloud.com

同时,我将我的html文件中的表单头改为:

<form name="pc_request_form" action="http://webcoupon.us/RequestPointCard" method="POST">

我的问题:在此之后,每当我提交表单时,我都会收到一条 http 错误消息:

Request method 'GET' not supported

同时,我的应用日志中也出现了这样的错误信息:

09:29:25,034 WARN [org.springframework.web.servlet.PageNotFound] Request method 'GET' not supported

这个错误消息(在我的应用日志中)让我相信

  1. http 请求(表单提交)中的 http://webcoupon.us 已按预期正确解析为 https://coupon-liquibil.rhcloud.com。但是
  2. http://webcoupon.us 被解析后,请求被服务器(我的应用程序)解释为 GET,而不是预期的 POST 请求——这是为什么?

该应用是在 Springframework REST API 中实现的。我还尝试过 Godaddy 进行域转发。结果是一样的。 [END]

【问题讨论】:

    标签: html post http-post spring-rest


    【解决方案1】:

    http://webcoupon.us/RequestPointCard 的 POST 返回 HTTP 重定向响应:

    HTTP/1.1 301 Moved Permanently
    Location: https://app-coupondev.b9ad.pro-us-east-1.openshiftapps.com/RequestPointCard
    

    这会破坏 POST,301 仅受 GET/HEAD 支持。在此之后,用户代理(可能)会发出一个裸露的 GET 请求。

    【讨论】:

    • 感谢您的回复。如果我理解正确:域转发 301 用于 GET/HEAD 请求,而不是用于 POST?
    • 我在网上搜索了“域转发”的描述,但找不到“域转发仅用于 GET/HEAD 请求”这样的说法。我是不是误会了?
    猜你喜欢
    • 2018-04-04
    • 1970-01-01
    • 2013-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    • 1970-01-01
    相关资源
    最近更新 更多