Django / App-Engine:执行HTTP POST请求时获取HTML错误响应(HTTP GET工作)

时间:2021-10-08 18:16:02

If I do a nc 192.168.2.10 8080 and then GET /test/ I get as expected a JSON response:

如果我执行nc 192.168.2.10 8080然后GET / test /我按预期获得JSON响应:

Content-Type: text/javascript
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 74

{ ... a JSON message ...}

However, if I do a POST /test/ I get the following HTML doc as a result:

但是,如果我进行POST /测试/我得到以下HTML文档:

<head>
<title>Error response</title>
</head>
<body>
<h1>Error response</h1>
<p>Error code 400.
<p>Message: Bad HTTP/0.9 request type ('POST').
<p>Error code explanation: 400 = Bad request syntax or unsupported method.
</body>

Anyone an idea where the problem could be?

任何人都知道问题可能在哪里?

1 个解决方案

#1


1  

As Nick Johnson said in his comment, try a tool that forms requests properly for you.

正如尼克约翰逊在评论中所说,尝试一种能够为您正确形成请求的工具。

Another common source of these sorts of errors is trying to parse a GET request on the server (for arguments or whatever) while you're getting a post request.

这些错误的另一个常见原因是尝试在获取发布请求时解析服务器上的GET请求(用于参数或其他)。

Also something that always gets me, but that's a 403, is csrf protection. Remember to turn it off for requests you want to make via curl and similar :)

还有一些东西总是让我,但这是一个403,是csrf保护。请记住将其关闭,以便通过curl和类似的方式制作请求:)

#1


1  

As Nick Johnson said in his comment, try a tool that forms requests properly for you.

正如尼克约翰逊在评论中所说,尝试一种能够为您正确形成请求的工具。

Another common source of these sorts of errors is trying to parse a GET request on the server (for arguments or whatever) while you're getting a post request.

这些错误的另一个常见原因是尝试在获取发布请求时解析服务器上的GET请求(用于参数或其他)。

Also something that always gets me, but that's a 403, is csrf protection. Remember to turn it off for requests you want to make via curl and similar :)

还有一些东西总是让我,但这是一个403,是csrf保护。请记住将其关闭,以便通过curl和类似的方式制作请求:)