App Engine:400 - 您的客户发布了格式错误或非法请求 [英] App Engine : 400 - Your client has issued a malformed or illegal request

查看:179
本文介绍了App Engine:400 - 您的客户发布了格式错误或非法请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在过去的3到4周内向应用引擎发出请求时遇到了此错误。某些请求 - 特别是HTTP DELETE请求,从google服务器返回这个错误。



其他人报告了同样的错误 - 我可以找到3个结果


  1. 这是由陈旧的Cookie引起的 - 清除您的Cookie并且运行良好 Gmail帮助 -

  2. 这是由格式错误的网址引起的 - 只有我可以找到与urlfetch()相关 - 网址中的空格 - App引擎组# 1 App Engine Group#2

  3. 没有解决方案 - 零星的behaiour,只有IE浏览器。 App Engine Group#3 App Engine Group#4

我现在每次都在浏览器中看到这种行为。我可以彻底清除Chrome,Firefox,Safari中的缓存/ cookies等,重新启动浏览器,并仍然可靠地得到相同请求的这个错误,所以我不认为它的cookie相关。无论如何,我可以发出GET,POST& PUT请求同一个cookie没有问题。



鉴于它在特定的DELETE请求中可靠地发生,格式不正确的URL似乎是最可能的,但是我的URL非常简单,并且在dev服务器上正常工作



Firebug显示请求标头(因为它们包含标识数据,所以我已经消灭了这些密钥,但是通过从密钥的中心 - 既不保证我不会无意中删除任何前导或尾随空白)

 请求URL:http ://my-app.appspot.com/agprhcjgLEgVLbm93dCItX0RrbV9Ea25vd3RfbmV0X19wccxDA/Task.xml 
请求方法:DELETE
状态码:400错误请求

请求头文件
接受: * / *
Cache-Control:max-age = 0
Content-Type:application / x-www-form-urlencoded
Origin:http://my-app.appspot.com
Referer:http://my-app.appspot.com/
User-Agent:Mozilla / 5.0(Macintosh; U;英特尔Mac OS X 10_ 6_4; AppleWebKit / 533.4(KHTML,如Gecko)Chrome / 5.0.375.99 Safari / 533.4
X-Requested-With:XMLHttpRequest

表单数据
entity_key:agprdC1hcjYLEgVLbm93dCIrX09Ea25vd3RfbmV0X19wMQw

响应标题
内容长度:1350
内容类型:text / html; charset = UTF-8
日期:2010年7月30日星期五,格林威治标准时间
服务器:GFE / 2.0

响应头显示请求从未将其发送到应用程序引擎服务器(并且我的应用程序引擎日志承担了这一点) - 成功将其发送到应用程序引擎服务器的请求看起来更像这为响应标题 - $ / $>

 缓存控制:无缓存
内容长度:4332
内容 - 类型:application / xml
日期:2010年7月30日星期五,星期五
过期时间:1990年1月1日星期五00:00:00 GMT
服务器:Google Frontend
X-AppEngine-Estimated-CPM-US-Dollars:$ 0.004033
X-AppEngine-Resource-Usage:ms = 573 cpu_ms = 146 api_cpu_ms = 30

我使用jquery的$ .ajax()方法构造请求,并将类型设置为DELETE。而且,尽管问题开始出现间歇性,但这些工作与上周一样有效。现在,我做的没有任何效果。



目前我认为这是Google服务器上的某种配置错误/更改,缓慢地在网络中蔓延 - 这解释了为什么它开始间歇性地,稳步增加,现在一直在发生。



其他人能够向Google应用引擎发出HTTP DELETE请求吗?如果你是,你的URL是否包含应用程序引擎实体键?你能看到我的任何狡猾吗?



任何其他指针将不胜感激。干杯,

Colin b
$ b

谷歌服务器的完整响应是 -

 < html>< head> 
< meta http-equiv =content-typecontent =text / html; charset = utf-8>
< title> 400错误请求< / title>
< style><! -
body {font-family:arial,sans-serif}
div.nav {margin-top:1ex}
div.nav {font-size:10pt; font-family:arial,sans-serif}
span.nav {font-size:10pt; font-family:arial,sans-serif; font-weight:bold}
div.nav A,span.big {font-size:12pt;颜色:#0000cc}
div.nav A {font-size:10pt;颜色:黑色}
A.l:link {color:#6f6f6f}
A.u:link {color:green}
// - >< / style>
< script><! -
var rc = 400;
// - >
< / script>
< / head>
< body text =#000000 bgcolor =#ffffff>
< table border = 0 cellpadding = 2 cellspacing = 0 width = 100%>< tr>< td rowspan = 3 width = 1%nowrap>
< b>< font face = times color =#0039b6 size = 10> G< / font>< font face = times color =#c41200 size = 10> o< / font>< font face = font size = 10>< font color =#f3c518 size = 10> o< / font>< font face = times color =#0039b6 size = 10> g< / font>< font face = times color =#30a72f size = 10> / font>< font face = times color =#c41200 size = 10> e< / font>& nbsp;& nbsp;< / b>
< td>& nbsp;< / td>< / tr>
< tr>< td bgcolor =#3366cc>< font face = arial,sans-serif color =#ffffff>< b>错误< / b>< / td> ;< / TR>
< tr>< td>& nbsp;< / td>< / tr>< / table>
< blockquote>
< H1>错误请求< / H1>
您的客户发布了格式不正确或非法的请求。

< p>
< / blockquote>
< / body>< / html>


解决方案

使用HTTP DELETE,URI应完全识别资源被删除。在请求正文中发送额外数据是意外的,和App Engine上,不支持
$ b


的确,当appspot前端看到包含
主体的
a DELETE请求时,比如你的应用程序,他们会返回一个
501.但是,如果你删除了这个主体,那么它就会有200个。


根据后面的讨论,看起来他们认为400比501更合适。无论如何,如果你忽略了body并将你的实体键移动到URI中,你应该没问题。


I have been running into this error for the last 3 or 4 weeks making requests to app engine. Certain requests - especially HTTP DELETE requests, are having this error returned from the google server.

Others have reported the same error - with 3 outcomes I can locate

  1. It is caused by stale cookies - clear your cookies and it runs fine gmail help -
  2. It is caused by a malformed url - only cases I can find relate to urlfetch() - spaces in the url - App engine Group #1, App Engine Group #2
  3. No resolution - sporadic behaiour, IE only. App Engine Group #3, App Engine Group #4

I'm now getting this behaviour all the time, in every browser. I can completely clear down the cache/cookies etc. in Chrome, Firefox, Safari, restart the browser and still reliably get this error on the same requests, so I don't think its cookie related. In any case I can issue GET, POST & PUT requests no problem with the same cookie.

Given that it occurs reliably on specific DELETE requests, the malformed URL would seem the most likely, however my URL is really very simple, and works fine on the dev server

Firebug shows the request headers as (I've munged the keys as they contain identifying data, but did so by removing characters from the centre of the key - not either end to guarantee I didn't inadvertently remove any leading or trailing whitespace)

    Request URL:http://my-app.appspot.com/agprhcjgLEgVLbm93dCItX0RrbV9Ea25vd3RfbmV0X19wccxDA/Task.xml
    Request Method:DELETE
    Status Code:400 Bad Request

    Request Headers
    Accept:*/*
    Cache-Control:max-age=0
    Content-Type:application/x-www-form-urlencoded
    Origin:http://my-app.appspot.com
    Referer:http://my-app.appspot.com/
    User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4
    X-Requested-With:XMLHttpRequest

    Form Data
    entity_key:agprdC1hcjYLEgVLbm93dCIrX09Ea25vd3RfbmV0X19wMQw

    Response Headers
    Content-Length:1350
    Content-Type:text/html; charset=UTF-8
    Date:Fri, 30 Jul 2010 15:51:58 GMT
    Server:GFE/2.0

The response headers show that the request never made it to the app engine servers (and my app engine logs bear this out) - a request which successfully makes it to the app engine server looks more like this for response headers -

Cache-Control:no-cache
Content-Length:4332
Content-Type:application/xml
Date:Fri, 30 Jul 2010 11:08:21 GMT
Expires:Fri, 01 Jan 1990 00:00:00 GMT
Server:Google Frontend
X-AppEngine-Estimated-CPM-US-Dollars:$0.004033
X-AppEngine-Resource-Usage:ms=573 cpu_ms=146 api_cpu_ms=30

I am constructing the requests using jquery's $.ajax() method and setting the type as 'DELETE'. Also, these have worked as recently as last week, although the problem was starting to appear intermittently. Right now, nothing I do has any effect.

At the moment I'm thinking this is some sort of configuration error/change on google servers , slowly creeping across their network - which explains why it began intermittently, steadily increased, and now happens all the time.

Is anyone else able to issue HTTP DELETE requests to google app engine? If you are, do your URL's contain app engine entity keys? Can you see anything dodgy with mine?

Any other pointers would be greatly appreciated. Cheers,

Colin

The full response from the google server is -

<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>400 Bad Request</title>
<style><!--
body {font-family: arial,sans-serif}
div.nav {margin-top: 1ex}
div.nav A {font-size: 10pt; font-family: arial,sans-serif}
span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold}
div.nav A,span.big {font-size: 12pt; color: #0000cc}
div.nav A {font-size: 10pt; color: black}
A.l:link {color: #6f6f6f}
A.u:link {color: green}
//--></style>
<script><!--
var rc=400;
//-->
</script>
</head>
<body text=#000000 bgcolor=#ffffff>
<table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td rowspan=3 width=1% nowrap>
<b><font face=times color=#0039b6 size=10>G</font><font face=times color=#c41200 size=10>o</font><font face=times color=#f3c518 size=10>o</font><font face=times color=#0039b6 size=10>g</font><font face=times color=#30a72f size=10>l</font><font face=times color=#c41200 size=10>e</font>&nbsp;&nbsp;</b>
<td>&nbsp;</td></tr>
<tr><td bgcolor="#3366cc"><font face=arial,sans-serif color="#ffffff"><b>Error</b></td></tr>
<tr><td>&nbsp;</td></tr></table>
<blockquote>
<H1>Bad Request</H1>
Your client has issued a malformed or illegal request.

<p>
</blockquote>
<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor="#3366cc"><img alt="" width=1 height=4></td></tr></table>
</body></html>

解决方案

With an HTTP DELETE, the URI should fully identify the resource to be deleted. Sending additional data in the request body is unexpected, and on App Engine, unsupported:

Indeed, when the appspot frontends see a DELETE request that includes an body, such as your app, they return a 501. But, if you remove the body then it will serve a 200.

Based on the subsequent discussion, it looks like they decided 400 was more appropriate than 501. In any event, if you omit the body and move your entity key into the URI, you should be fine.

这篇关于App Engine:400 - 您的客户发布了格式错误或非法请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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