HTTP redirector app lazarus / 8-Other ---------------------------------------------------------------------- tudi_x · 2017-11-24 15:17 hi All, i am trying to troubleshoot a HTTP POST i am receiving on a socket from an application i did now write. is there an application i could use to route this HTTP POST from http://127.0.0.1:xxxx to http://y.y.y.y:zzzz? i would like to send the request to something like https://hookbin.com/bin/vyxDpGP4 to double check my work. thank you ---------------------------------------------------------------------- Leledumbo · 2017-11-25 17:25 Make a proxy app (it's no different from normal HTTP server from client POV), check the HTTP_HOST and REQUEST_URI headers, if they match the URL you want to redirect, then modify them and forward the request to the address you want. Point the browser's proxy to your proxy app. Something like: 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 {$mode objfpc} uses  fphttpapp,httproute,httpdefs,fphttpclient; procedure RedirectIfMatches(ARequest : TRequest; AResponse : TResponse);var  Client: TFPHTTPClient;begin  Client := TFPHTTPClient.Create(nil);  try    if (ARequest.Method = 'POST') and (ARequest.URL = 'http://127.0.0.1/xxxx') then begin      // redirect request      AResponse.Content := Client.Post('http://y.y.y.y:zzzz');    end else begin      // forward request, note that this discards headers and body that might present in the request      case ARequest.Method of      'GET': AResponse.Content := Client.Get(ARequest.URL);        'POST': AResponse.Content := Client.Post(ARequest.URL);        // complete the other methods      end;    end;  finally    Client.Free;  end;end; begin  HTTPRouter.RegisterRoute('*path',@RedirectIfMatches);  Application.Port := 8888;  Application.Initialize;  Application.Run;end.