idHTTP Post Response html hacked

Asked

Viewed 597 times

4

Buenas.

I’m doing a Post via idHTTP where the result comes in a StringStream.

The problem that this result is coming in half. In case, by cutting the response html.

There Is A Way To Buffer This Post?

Note: I use Delphixe7.

  var
    fHTTP: THTTP;//Classe que utilizo para alimentar o idHTTP
    slParam: TStringList;
  begin
    fHTTP := THTTP.Create;
    slParam := TStringList.Create;
    try
      slParam.Add('modo=C');
      slParam.Add('NumeroRENACH=');
      slParam.Add('txtDocPrincipal=');
      slParam.Add('oculto=');
      slParam.Add('txtCodigo='+ fCaptcha);
      slParam.Add('Submit=Consultar');

      fHTTP.pLimpaParams;
      fHTTP.Params.Host := 'consultas.detrannet.sc.gov.br';
      fHTTP.Params.Connection := 'keep-alive';
      fHTTP.Params.ContentLength := Length(slParam.Text);
      fHTTP.Params.CacheControl := 'max-age=0';
      fHTTP.Params.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36';
      fHTTP.Params.ContentType := 'application/x-www-form-urlencoded';
      fHTTP.Params.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
      fHTTP.Params.AcceptEncoding := 'gzip, deflate';
      fHTTP.Params.AcceptLanguage := 'pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4';
      fHTTP.Params.CustomHeaders.Values['Cookie'] := ACookie;
      fHTTP.Params.CustomHeaders.Values['Upgrade-Insecure-Requests'] := '1';

      fHTTP.Params.ProtocolVersion := 1;

      fHTTP.Post('http://consultas.detrannet.sc.gov.br'+RemotePath,slParam);
  finally
    FreeAndNil(fHTTP);
    FreeAndNil(slParam);
  end;
end;

1 answer

1

I believe the problem is here. fHTTP.Params.ContentLength := Length(slParam.Text); The length of your slParam should be very small, do a test, put 10,000 in Contentlength, that’s probably it. The contentlength that dictates the size of the answer you will receive.

If it doesn’t work, check if the component has the attribute Response, probably in Response will also have Contentlength, then you arrow it to a large number to perform this test. If you have the attribute Sponse I believe it would look like this...

fHTTP.Response.ContentLength := 10000
  • Thanks for the answer. So Postdata is just that on the stringlist. I discovered that the problem was not in idHTTP but in a function that saved to file where I had not done the Unicode adjustment because I copied from the Delphi 7 project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.