Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django/App引擎:在执行HTTP POST请求时获取HTML错误响应(HTTP GET works)_Django_Json_Google App Engine_Httprequest - Fatal编程技术网

Django/App引擎:在执行HTTP POST请求时获取HTML错误响应(HTTP GET works)

Django/App引擎:在执行HTTP POST请求时获取HTML错误响应(HTTP GET works),django,json,google-app-engine,httprequest,Django,Json,Google App Engine,Httprequest,如果我执行nc192.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 ...} 但是,如果执行POST/test/操作,则会得到以下HTML文档: <head> <title>

如果我执行
nc192.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 ...}
但是,如果执行
POST/test/
操作,则会得到以下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>

错误响应
错误响应
错误代码400。
消息:错误的HTTP/0.9请求类型(“POST”)。
错误代码解释:400=错误的请求语法或不支持的方法。

有人知道问题出在哪里吗?

正如尼克·约翰逊(Nick Johnson)在评论中所说的那样,尝试一种为您正确生成请求的工具

此类错误的另一个常见来源是,在获取post请求时,试图在服务器上解析GET请求(针对参数或其他内容)


还有一件事总是让我着迷,但那是403,是csrf保护。记住,对于您希望通过curl和类似方式发出的请求,请将其关闭:)

听起来您没有正确地向服务器发送请求。使用wget或curl,这样您就可以在不依赖HTTP语法知识的情况下对其进行测试。