Search code examples
stringdelphihttpindyidhttp

Delphi - Indy TIdHttp.Get with large URL length


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?


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