Request-URI Too Large [duplicate]

家住魔仙堡 提交于 2019-12-19 05:33:07

问题


Got this error on a big $_GET query in size ~9 000 symbols (they are divided into ~10 variables).

Request-URI Too Large

The requested URL's length exceeds the capacity limit for this server.

What is a workaround for this problem?


回答1:


There is no workaround if you want pass all these info with GET without change server configuration.

Other solutions:

  • Use POST with a form (or an hidden form and add onclick event at your link that submit it)
  • Use Session. When the server generates the link, store it in $_SESSION with an unique id (or RID, it can be md5 of complete URI) and pass it via GET.
  • Use Database or file storage (with the same procedure of session)



回答2:


This worked for me (it needs formData support):

<script>
  //Load form
  var formData = new FormData();
  formData.append("param_name1", "param_content1");
  formData.append("param_name2", "param_content2"); 
  formData.append("param_nameN", "param_contentN"); 

  //Send form via AJAX
  var xhr = new XMLHttpRequest();
  xhr.open("POST", YOUR_URL);  
  xhr.send(formData);
</script>



回答3:


Well an URI actually have a character limit depending on several things. You can check it out at

  • http://en.wikipedia.org/wiki/Query_string#Compatibility_issues

One workaround is to use POST instead of GET if you are the one developing the server too.



来源:https://stackoverflow.com/questions/9877744/request-uri-too-large

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!