我想使用Indy 10的GET方法,但是,我的URL長度大於255個字符。 而GET方法只接受「字符串」參數。德爾福-Indy TIdHttp.Get具有較大的URL長度
body := httpCom.Get('..........wide string.........')
德爾福的編譯器給我的錯誤:
"String literals may have at most 255 elements"
是否有任何解決方案或其他第三方組件來解決這個問題?
我想使用Indy 10的GET方法,但是,我的URL長度大於255個字符。 而GET方法只接受「字符串」參數。德爾福-Indy TIdHttp.Get具有較大的URL長度
body := httpCom.Get('..........wide string.........')
德爾福的編譯器給我的錯誤:
"String literals may have at most 255 elements"
是否有任何解決方案或其他第三方組件來解決這個問題?
那沒有string類型,但IDE的問題,你可以像這樣寫
Const
C_URL = 'A long text with 255 Characters ....to be contionued ...'
+'more content....to be contionued ... '
+'more more content....to be contionued ... '
+'enough content';
begin
IDHTTP1.Get(C_URL);
end;
或
IDHTTP1.Get('A long text with 255 Characters ....to be contionued ...'
+'more content....to be contionued ... '
+'more more content....to be contionued ... '
+'enough content');
OMG!它的工作! Thaaaaanks sooo非常花花公子! – user2611996
TIdHTTP
對URL長度沒有任何限制,更不用說255個字符的限制。然而,HTTP服務器可能會給其結束了這樣的限制,如果確實如此,則請求將失敗與HTTP 414 Request-URI Too Long
錯誤代碼,每RFC 2616 Section 10.4.15:
10.4.15 414 Request-URI Too Long
The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information, when the client has descended into a URI "black hole" of redirection (e.g., a redirected URI prefix that points to a suffix of itself), or when the server is under attack by a client attempting to exploit security holes present in some servers using fixed-length buffers for reading or manipulating the Request-URI.
我沒有收到來自服務器的結果錯誤。 德爾福的編譯器給我的錯誤: 「字符串文字可能有至多255個元素」。 代碼: body:= httpCom.Get('.......... wide string .........'); – user2611996
儘管它沒有回答你的問題,但我認爲雷米發佈了這個答案,因爲當有人將谷歌例如['TIdHTTP URL length'](http://www.google.com/?q=TIdHTTP%20URL%20length),那麼它會導致你的問題,這篇文章描述了'TIdHTTP'控件和HTTP協議本身的URL長度限制。我想這很好。 OMG! – TLama
的可能重複的[如何DELPHI '字符串' 文字超過255?](http://stackoverflow.com/questions/8767899/how-can-delphi-字符串文字是超過255) – bummi