2

I'm trying to use the GET method from Indy 10 however, my URL's length is bigger than 255 chars. And GET method only accepts "string" parameters.

body := httpCom.Get('..........wide string.........')

Delphi's compiler give me the error:

"String literals may have at most 255 elements"

Is there any solution or different third-party component to solve this?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 1
    possible duplicate of [how can delphi 'string' literals be more than 255?](http://stackoverflow.com/questions/8767899/how-can-delphi-string-literals-be-more-than-255) – bummi Jul 23 '13 at 20:04

2 Answers2

6

That no problem of the string type but the IDE, you can write it like this e.g.

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;

or

  IDHTTP1.Get( 'A long text with 255 Characters ....to be contionued ...'
          +'more content....to be contionued ... '
          +'more more content....to be contionued ... '
          +'enough content');
bummi
  • 27,123
  • 14
  • 62
  • 101
3

TIdHTTP does not impose any limit on URL length, let alone a 255 character limit. However, an HTTP server might impose such a limit on its end, and if it does then the request should fail with an HTTP 414 Request-URI Too Long error code, per 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.

Community
  • 1
  • 1
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • I'm not getting a result error from server. Delphi's compiler give me the error: "String literals may have at most 255 elements". Code: body := httpCom.Get('..........wide string.........'); – user2611996 Jul 23 '13 at 19:47
  • 2
    Though it doesn't answer your question, I think Remy posted this answer because when someone will Google e.g. [`TIdHTTP URL length`](http://www.google.com/?q=TIdHTTP%20URL%20length) then it will result to your question and this post describes URL length limits of `TIdHTTP` control and HTTP protocol itself. And that's fine I think. – TLama Jul 23 '13 at 21:10