Question

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?

Was it helpful?

Solution

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');

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top