Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi IdHTTP.Post als HTTP/1.1 verschicken und Rang IdHTTP.Request (https://www.delphipraxis.net/134293-idhttp-post-als-http-1-1-verschicken-und-rang-idhttp-request.html)

Hallo_Thomas 19. Mai 2009 13:13


IdHTTP.Post als HTTP/1.1 verschicken und Rang IdHTTP.Request
 
Liste der Anhänge anzeigen (Anzahl: 2)
Hallo,

habe folgende Probleme, mein Post wird immer als POST / HTTP/1.0 verschickt, möchte es aber als POST / HTTP/1.1 verschicken?
Ich weiß nicht wo der Fehler liegt

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  data: TIdMultiPartFormDataStream;
begin
  data := TIdMultiPartFormDataStream.Create;
  IdHTTP1.ProtocolVersion:=pv1_1;
  IdHTTP1.Request.UserAgent:='null';
  IdHTTP1.Request.Accept:='eins';
  IdHTTP1.Request.AcceptCharSet:='zwei';
  IdHTTP1.Request.AcceptLanguage:='drei';
  try
    { add the used parameters for the script }
    data.AddFormField('param1', 'value1');
    data.AddFormField('param2', 'value2');
    data.AddFormField('param3', 'value3');
    { Call the Post method of TIdHTTP and read the result into TMemo }
    Memo1.Lines.Text := IdHTTP1.Post('http://www.delphipraxis.net', data);
  finally
    data.Free;
  end;
end;

Wie kann ich die Rangfolge von IdHTTP1.Request verändern, so das zum Beispiel der "User-Agent: null" vor Accept steht?


Delphi-Quellcode:
[*]E Žîâ@ €Á¬À¨²U
"- PF6Š\û¥cÒPÿÿ|v POST / HTTP/1.0
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------051909045300140
Content-Length: 281
Host: [url]www.delphipraxis.net[/url]
Accept: eins
Accept-Charset: zwei
Accept-Encoding: identity
Accept-Language: drei
User-Agent: null
Dankeschön Thomas

mjustin 19. Mai 2009 13:33

Re: IdHTTP.Post als HTTP/1.1 verschicken und Rang IdHTTP.Req
 
Indy verwendet immer 1.0, siehe IdHTTP.pas:

Zitat:

// Currently when issuing a POST, IdHTTP will automatically set the protocol
// to version 1.0 independently of the value it had initially. This is because
// there are some servers that don't respect the RFC to the full extent. In
// particular, they don't respect sending/not sending the Expect: 100-Continue
// header. Until we find an optimum solution that does NOT break the RFC, we
// will restrict POSTS to version 1.0.
Eventuell bietet Synapse 1.0.

Oder es hilft, die Options Property hoKeepOrigProtocol zu setzen (auch aus IdHTTP.pas):

Zitat:

// If hoKeepOrigProtocol is SET, is possible to assume that the developer
// is sure in operations of the server
d.h. es funktioniert eventuell mit manchen Servern, aber nicht unbedingt mit jedem.


Cheers,


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:43 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz