Safari 3.2.1 发送 POST 后跟 GET 请求

发布于 2024-07-10 04:00:15 字数 2282 浏览 10 评论 0 原文

我有一个在 Tomcat 5.5.27 和 5.5.26 上运行的 servlet,并且有一个带有 POST 方法的 Web 表单。 如果我使用 Safari 3.2.1,我从日志中看到 Tomcat 收到一个 POST,然后立即/同时收到 GET,但失败了。 如果我使用 Firefox 3.0.5,我发现它只发送 POST 并且一切正常。

尝试使用 Eclipse 进行调试,我发现使用 Safari 时调用的是 doGet() 方法,而使用 Firefox 时调用的是 doPost() 方法。

实际上,Safari 似乎同时触发 POST,然后立即触发 GET,而 Firefox 只触发 POST(因为它应该根据 HTML 表单)。

还有其他人经历过这个吗? 这种情况有解决办法吗?

以下是 HTML 表单的片段:

<form action="/vidisearch/Search" method="post" name="SearchForm" id="SearchForm">
    <div class="input required">
    <label for="Concepts">Concepts, comma separated<br />
    ex. (remove quotes) &quot;man-made object, cemetery, graphic event, atmospheric event, tool event&quot;</label>
    <input name="concepts" type="text" value="" id="concepts" />
    </div>

    <div class="input required">
    <label for="Operators">Operators, comma separated<br />
    ex. (remove quotes) &quot;NOT, AND, OR, AND, AND&quot;</label>
    <input type="text" name="operators" value="" id="operators" />
    </div>

    <div class="input required">
    <label for="Specializations">Specializations, comma separated<br />
    ex. (remove quotes) &quot;true, false, false, true, false&quot;</label>
    <input type="text" name="specializations" value="" id="specializations" />
    </div>

    <div class="input required">
    <label for="Results">Various parameters</label>
    <table width="100%" border="0" style="border: 0;">
    <tr>
    <td>Ontology ID<br />
    <input name="ontologyID" type="text" id="ontologyID" value="" /></td>
    <td>Result page<br />
    <input name="page" type="text" id="page" value="0" /></td>
    <td>Shots per page<br />
    <input name="shotsPerPage" type="text" id="shotsPerPage" value="20" /></td>
    <td>New search<br />
    <input name="newSearch" type="text" id="newSearch" value="true" /></td></tr>
    </table>
    </div>

    <div class="submit"><input type="submit" value="Search" /></div>
</form>

I've a servlet running on Tomcat 5.5.27 and 5.5.26 and have a web form with POST method.
If I use Safari 3.2.1 I see from the logs that Tomcat receives a POST followed immediately/contemporarily by GET and it fails.
If I use Firefox 3.0.5 I see that it sends only POST and everything works.

Trying to debug with Eclipse I see that when using Safari it is the doGet() method that is called while when using Firefox is doPost().

Practically it seems that Safari fires both POST and then immediately GET, while Firefox fires only POST (as it should according to the HTML form).

Is there somebody else who as experienced this ? In this case is there a solution ?

Here is a snippet of the HTML form:

<form action="/vidisearch/Search" method="post" name="SearchForm" id="SearchForm">
    <div class="input required">
    <label for="Concepts">Concepts, comma separated<br />
    ex. (remove quotes) "man-made object, cemetery, graphic event, atmospheric event, tool event"</label>
    <input name="concepts" type="text" value="" id="concepts" />
    </div>

    <div class="input required">
    <label for="Operators">Operators, comma separated<br />
    ex. (remove quotes) "NOT, AND, OR, AND, AND"</label>
    <input type="text" name="operators" value="" id="operators" />
    </div>

    <div class="input required">
    <label for="Specializations">Specializations, comma separated<br />
    ex. (remove quotes) "true, false, false, true, false"</label>
    <input type="text" name="specializations" value="" id="specializations" />
    </div>

    <div class="input required">
    <label for="Results">Various parameters</label>
    <table width="100%" border="0" style="border: 0;">
    <tr>
    <td>Ontology ID<br />
    <input name="ontologyID" type="text" id="ontologyID" value="" /></td>
    <td>Result page<br />
    <input name="page" type="text" id="page" value="0" /></td>
    <td>Shots per page<br />
    <input name="shotsPerPage" type="text" id="shotsPerPage" value="20" /></td>
    <td>New search<br />
    <input name="newSearch" type="text" id="newSearch" value="true" /></td></tr>
    </table>
    </div>

    <div class="submit"><input type="submit" value="Search" /></div>
</form>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

空城旧梦 2024-07-17 04:00:15

我认为您的图像标签的 src 为空。

I think you have an image tag that has an empty src.

凌乱心跳 2024-07-17 04:00:15

如果没有看到表单的 HTML,很难说,但也许您的提交按钮是用链接包裹的,而 Safari 既会 POST 表单,又会跟随链接(通过 GET)。

It's hard to say without seeing your HTML for the form, but perhaps your submit button is a wrapped with a link, and Safari is both POSTing the form and following the link (via GET).

梦太阳 2024-07-17 04:00:15

我不确定发生了什么,但我所知道的是您需要提供更多信息。

也许它会发送 GET 来获取相关资源(例如图像),而 Firefox 将它们保留在缓存中,或者您将表单提交按钮放在 中。 例如,标签。

另一种选择是 Javascript 不兼容,以防您通过 Javascript 提交某些内容。

嗅探流量(查看 FiddlerWireshark)并查看 Safari 试图获取什么以及正在发布什么

I'm not sure what's happening but what I do know is that you need to provide more information.

Maybe it's sending a GET for associated resources (like images) whereas Firefox keeps them in the cache, or you have the form submit button inside an <a> tag, for instance.

Another alternative is a Javascript incompatibility, in case you are submitting something via Javascript.

Sniff the traffic (check out Fiddler or Wireshark) and see what is Safari trying to GET and what's it is POSTing

蓝海 2024-07-17 04:00:15

我对 Safari 的行为感到非常困惑,因为我提醒过它不久前是有效的。 我担心最新的升级之一会破坏某些东西。

使用 HTTPScoop 我发现 Safari 在收到响应时显然会先触发 POST,然后再触发 GET。 然而,我认为它实际上会同时触发两个请求,因为 POST 和 GET 的两个响应的日期+时间是相同的。

响应是 RSS 源并具有 HTTP/1.1 200 OK 代码。 第二个 GET 请求相同的请求 URL (http://127.0.0.1:8180/vidisearch/Search< /a>) 的 POST 但正文是 0 字节,它当然没有 GET 参数,并且由于缺少参数,答案是错误的。

相反,Firefox 只触发 POST 并获得正确的答案。

I'm quite puzzled by the behaviour of Safari since I remind that sometime ago it worked. I'm fearing that one of the latest upgrades has broken something.

Using HTTPScoop I've seen that apparently Safari fires POST followed by GET when it gets the response. I think however that it actually fires both requests at the same time since the date+time of the two responses is the same for both POST and GET.

The response is a RSS feed and has the HTTP/1.1 200 OK code. The second GET asks for the same request URL (http://127.0.0.1:8180/vidisearch/Search) of the POST but the body is 0 bytes, it has of course no GET parameters and the answer is wrong because of the missing parameters.

Firefox instead fires only the POST and gets the correct answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文