重定向后,Post方法将转换为GET [英] Post method gets converted to GET after redirection

查看:110
本文介绍了重定向后,Post方法将转换为GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与搜索相关的POST调用,就像我正在发送一些数据作为参数来调用,而某些数据在有效负载中一样.在获得302之后,它被重定向了.但是问题是,一旦它被重定向了,POST调用就被转换为GET调用和有效负载丢失.结果是我无法获得所需的搜索结果.是否有与配置有关的内容可能丢失了??

I have one POST call related to search.It is like I am sending some data as parameters to call and some in payload.after getting 302 it gets redirected.But the issue is once it gets redirected,POST call gets converted to GET call and payload is lost.As a result I am unable to get desired search result.Is there anything related to config that I might be missing??

推荐答案

是的,这是正确的行为.听起来您需要为此测试禁用自动重定向,请参见 configure .您可以这样做:

Yes this is the correct behavior. Sounds like you need to disable automatic re-directs for this test, see configure. You can do:

* configure followRedirects = false

然后手动获取重定向位置,如下所示:

And then get the redirect location manually as follows:

* def location = responseHeaders['Location'][0]

以该测试为例: redirect.feature

Refer to this test for an example: redirect.feature

这篇关于重定向后,Post方法将转换为GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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