#1 2019-02-05 12:35:52

egold2005
Member
Registered: 2019-01-28
Posts: 16

THttpClientSocket.Content is empty after POST request

Hello,

I am testing the framework for the purpose of creating a proxy server to a number of internal REST services.

I am overriding TSqlHttpServer.Request method with the following code

    vURL := Ctxt.URL;
    GetServiceConnectionPoint(vURL, vAddress, vPort);
    vClient := THttpClientSocket.Open(vAddress, vPort);
    try
       result := vClient.Request(Ctxt.URL, Ctxt.Method, 5000, Ctxt.InHeaders, Ctxt.InContent, Ctxt.InContentType, TRUE);
       Ctxt.OutContent := vClient.Content;
       Ctxt.OutContentType := vClient.ContentType;

       Ctxt.OutCustomHeaders := '';
       for vIdx := Low(vClient.Headers) to High(vClient.Headers) do
          Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + vClient.Headers[vIdx];
    finally
      vClient.free;
    end;

This works fine for a number of scenarios like .Get and .Delete, but it does not return anything in .Content for some POST requests, while the end point does return the content.

Any advice, other than read the docs and samples (i did that already).

Thanx alot.

Offline

#2 2019-02-06 03:32:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: THttpClientSocket.Content is empty after POST request

Your headers are missing a #13#10 between the lines.

Why not just use something like nginx as reverse proxy?
It was meant for this...

Offline

#3 2019-02-06 13:29:02

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: THttpClientSocket.Content is empty after POST request

ab wrote:

Your headers are missing a #13#10 between the lines.

Is it what you mean? This does not work properly either...

       Ctxt.OutCustomHeaders := '';
       for vIdx := Low(vClient.Headers) to High(vClient.Headers) do
          Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10 + vClient.Headers[vIdx];

Offline

Board footer

Powered by FluxBB