简体   繁体   English

有很多参数的Ajax GET请求发生错误

[英]error on Ajax GET request with a lots of parameters

Sending request with URL length ~ 4950 characters. 发送的请求的URL长度约为4950个字符。

Getting the following XMLHTTPRequest.ResponseText: 获取以下XMLHTTPRequest.ResponseText:

ERROR
The requested URL could not be retrieved

While trying to retrieve the URL: ##my long url##
The following error was encountered:
Invalid URL
Some aspect of the requested URL is incorrect. Possible problems:
Missing or incorrect access protocol (should be `http://'' or similar)
Missing hostname
Illegal double-escape in the URL-Path
Illegal character in hostname; underscores are not allowed
Your cache administrator is webmaster. 

But when I'm entering the same url in the browser it works just fine. 但是当我在浏览器中输入相同的URL时,它工作得很好。 I checked for possible errors(that are listed in the response text) - everything's ok. 我检查了可能的错误(在响应文本中列出) - 一切都好。

When the number of parameters is less than ~200 the script works, so the clue must be in some limits. 当参数数量小于〜200时,脚本可以工作,因此线索必须在某些限制内。 On the other hand there are no any settings in the apache or php or js. 另一方面,apache或php或js中没有任何设置。

Any advices or where should I look(some additional configs or whatever) for the solution? 任何建议或我应该在哪里寻找解决方案(一些额外的配置或其他)?

Sending request with URL length ~ 4950 characters. 发送的请求的URL长度约为4950个字符。

That is too much for Internet Explorer anyway. 无论如何,这对Internet Explorer来说太过分了。 Also possibly for Opera, which IIRC has a limit of 4096 bytes for GET requests. 也可能是Opera,IIRC对GET请求的限制为4096字节。

You should use POST for this amount of data. 您应该使用POST来获取此数据量。

Maximum URL length is 2,083 characters in Internet Explorer Internet Explorer中的最大URL长度为2,083个字符

Apache replies with 413 Entity Too Large if the URL exceeds approximately 4000 characters (request lines are capped to 8190 bytes ). 如果URL超过大约4000个字符(请求行上限为8190字节 ),Apache将回复413 Entity Too Large

Using the LimitRequestLine directive won't help, you'll have to recompile Apache with -D DEFAULT_LIMIT_REQUEST_LINE=some huge value if you absolutely want to send large GET requests. 使用LimitRequestLine指令无济于事,如果您绝对想要发送大型GET请求,则必须使用-D DEFAULT_LIMIT_REQUEST_LINE=some huge value重新编译Apache。

EDIT: Some thoughts about the ~4000 character cap: 8190 looks a lot like 8192 with two bytes reserved for the string terminator , so there's a good chance that Apache uses UCS-2 or similar to store request lines, since DEFAULT_LIMIT_REQUEST_LINE is expressed in bytes, not characters. 编辑:关于8190字符上限的一些想法: 8190看起来很像8192 with two bytes reserved for the string terminator ,所以很有可能Apache使用UCS-2或类似的字符来存储请求行,因为DEFAULT_LIMIT_REQUEST_LINE用字节表示而不是人物。

That would give a 4095 character cap per request line, ie a maximum URL length of 4079 characters (taking into account the initial GET and the final CR/LF pair), which would make sense. 这将为每个请求行提供4095个字符的上限,即最大URL长度为4079个字符(考虑到初始GET和最终的CR/LF对),这是有意义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM