[Solved] Sending Binary data using TFPHTTPServer and POST lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Amir61 · 2018-06-16 20:31 Hi all,   I am trying to send some binary data using TFPHTTPServer and POST. Here is the snippet of my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMyServer.HandleRequest(var ARequest: TFPHTTPConnectionRequest;  var AResponse: TFPHTTPConnectionResponse);...begin    Request := TRequestMessage.Create(AReqeust)    Response := TResponseMessage.Create;     Self.ServeRequest(ARequest, Request, Response);     BinData := '';    Response.SaveAsBinary(BinData);     AResponse.ContentType := 'application/octet-stream';    AResponse.ContentLength:= Length(BinData);    AResponse.Content := BinData;   ... end;  I noticed that the data I send and receive are different. After some more debugging, I figured out that the content of my "BinData" variable and AResponse.Content are different: For example, if BinData is #10#13#78#111, the value stored in AResponse.Content would be #10#10#78#111. I wonder if the issue is because of the ContentType? What ContentType should I use? ---------------------------------------------------------------------- Amir61 · 2018-06-16 23:44 Looks like the following works: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMyServer.HandleRequest(var ARequest: TFPHTTPConnectionRequest;  var AResponse: TFPHTTPConnectionResponse);...begin    Request := TRequestMessage.Create(AReqeust)    Response := TResponseMessage.Create;     Self.ServeRequest(ARequest, Request, Response);     BinData := '';    Response.SaveAsBinary(BinData);     AResponse.ContentType := 'text/html';    OutputStream := TStringStream.Create(BinData);    AResponse.ContentStreeam := OutputStream;    ... end;