如何使用 HttpWebRequest 在 Windows Phone 中发送长查询字符串 [英] How to send long query string in Windows Phone with HttpWebRequest

查看:62
本文介绍了如何使用 HttpWebRequest 在 Windows Phone 中发送长查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Facebook C# SDK 对 Facebook 进行 API 调用,但我似乎无法通过 HTTP GET 发送长查询字符串.我需要一个很长的 FQL 查询(select .. from .. where .. in )来执行,但我似乎无法发送它.如果查询较小,它确实发送成功并返回结果.不幸的是,由于 FQL 支持 GET 而不是 POST,我坚持使用 GET.

I am making an API call to Facebook, using the Facebook C# SDK, and I can't seem to send long query strings via HTTP GET. I need a long FQL query (select .. from .. where .. in ) to execute and I can't seem to send it. If the query is smaller, it does send successfully and return the results. Unfortunatelly, as FQL supports GET and not POST, I am stuck to GET.

如何增加 Windows Phone HttpWebRequest 中的默认查询字符串限制?

How can I increase the default query string limit in Windows Phone HttpWebRequest?

我使用的是 Windows Phone SDK 7.1,但在 Windows Phone 8 设备上进行测试.

I am using Windows Phone SDK 7.1, but testing on Windows Phone 8 device.

推荐答案

看来您需要切换到 http post(如果可能)或以某种方式优化您的请求.

It seems you need to switch to http post (if possible) or optimize your request somehow.

阅读 不同浏览器中 URL 的最大长度是多少?.虽然 HTTP 的官方标准说不应该有最大值,但实际上 有最大值.例如,IE 的上限为 2083 个字符.Windows Phone 似乎和 IE 有类似的限制.

Read What is the maximum length of a URL in different browsers?. While the official standard for HTTP says that there should be no maximum, in reality there are maximums. For example, IE have an upper bound of 2083 characters. Windows Phone seems to have similar limit to IE.

Microsoft Internet Explorer 具有最大统一资源定位器(URL) 长度为 2,083 个字符.Internet Explorer 也有一个最大值路径长度为 2,048 个字符.此限制适用于两个 POSTrequest 和 GET 请求网址.

Microsoft Internet Explorer has a maximum uniform resource locator (URL) length of 2,083 characters. Internet Explorer also has a maximum path length of 2,048 characters. This limit applies to both POST request and GET request URLs.

如果您使用的是 GET 方法,则最多只能有 2,048 个字符,减去实际路径中的字符数.

If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path.

但是,POST 方法不受 URL 大小的限制提交名称/值对.这些对在标头中传输而不是在 URL 中.

However, the POST method is not limited by the size of the URL for submitting name/value pairs. These pairs are transferred in the header and not in the URL.

RFC 2616,超文本传输​​协议 -- HTTP/1.1",没有指定对 URL 长度的任何要求.

RFC 2616, "Hypertext Transfer Protocol -- HTTP/1.1," does not specify any requirement for URL length.

来源:http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/f96622fe-4dcb-4d38-8831-4cfad1aa4a06/

这篇关于如何使用 HttpWebRequest 在 Windows Phone 中发送长查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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