procedure TForm1.buttAddDocumentClick(Sender: TObject);var aHTTP: THTTPSend;begin aHTTP := THTTPSend.Create; try WriteStrToStream(aHTTP.Document, '<document><title>Test document</title><body>Some text</body></document>'); aHTTP.MimeType := 'application/xml'; if aHTTP.HTTPMethod('POST', 'http://localhost:3000/documents.xml') then begin aHTTP.Document.Position := 0; Memo1.Lines.LoadFromStream(aHTTP.Document); end else ShowMessage('Can not POST'); finally aHTTP.Free; end;end;
DecomposeURL('h t tp://some.host.com/login.xml', sHost, sUrl, sPort); httpclient.Method := hmPost; httpclient.Port := sPort; httpclient.Host := sHost; httpclient.URI := sUrl; httpclient.AddExtraHeader('Keep-Alive: 300'); httpclient.AddExtraHeader('Connection: keep-alive'); httpclient.AddExtraHeader('Content-Length: 111'); // <-XML length httpclient.AddExtraHeader('Content-Type: application/xml; charset=utf-8'); httpclient.AddExtraHeader(LineEnding); httpclient.AddExtraHeader( '<?xml version="1.0"?>' + LineEnding + '<login>'+ LineEnding + 'dibo'+ LineEnding + '</login>' ); httpclient.SendRequest;