Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   http request (https://www.delphipraxis.net/174745-http-request.html)

Alterauge 7. Mai 2013 14:18

http request
 
hallo, was ist am quelltext falsch?
das telegramm wird nicht gesendet!

Delphi-Quellcode:
procedure TForm1.BitBtn1Click(Sender: TObject);
var request, content : string;
begin
 // http request
   Client.Host:='192.168.0.110';
   request := 'Post /telegramin/alarmgeber/index.xml HTTP/1.1';
   content := 'type=pocsag&function=a&address=1234567&flags=0&message=hallo'
   + 'Content-Type: application/x-www-form-urlencoded'
   + content;
 end;

Der schöne Günther 7. Mai 2013 14:23

AW: http request
 
Absicht, dass die Leerstelle zwischen 'hallo' und 'Content-Type' fehlt?

Bummi 7. Mai 2013 14:26

AW: http request
 
Was ist Client und warum sollte etwas gesendet werden.
Du setzt den Host und befüllst 2 Stringvariablen ....

Alterauge 7. Mai 2013 14:37

AW: http request
 
so hier ist der neue quelltext, der nicht geht?
warum ?

möchte ein telegramm zur schnittstelle senden!

Delphi-Quellcode:
var request, nl, content : string;
// http request
   content := 'type=pocsag&function=a&address=1234567&flags=0&message=hallo';
    if Client.Connected then Client.Disconnect;
     Client.Connect;
      nl := AnsiChar(#13) + AnsiChar(#10);
   request := 'POST /telegramin/alarmgeber/index.xml HTTP/1.1' + nl
   + 'Authorization: Basic uZtghzjuhZhujHu=' + nl
   + 'Content-Type: application/x-www-form-urlencoded' + nl
   + 'Host: 192.168.0.110' + nl
   + 'Content-Length: ' + IntToStr(length(content)) + nl
   + 'Expect: 100-continue' + nl
   + 'Connection: Keep-Alive'+ nl + nl
   + content;

taveuni 7. Mai 2013 14:39

AW: http request
 
Willst Du uns vergackeiern? Was ist Client, nl, und request. Wo sendest Du was?

mjustin 7. Mai 2013 14:44

AW: http request
 
Zitat:

Zitat von Alterauge (Beitrag 1214557)
so hier ist der neue quelltext, der nicht geht?
warum ?

Gibt es eine Fehlermeldung, und wenn ja, welche?

Alterauge 7. Mai 2013 14:46

AW: http request
 
Oh, habe ich vergessen!

Client ist eine IdTCPClient Komponente!

Sorry :-)

baumina 7. Mai 2013 14:48

AW: http request
 
Und wann teilst du dem Client den Request mit?

Alterauge 7. Mai 2013 14:53

AW: http request
 
wenn der button ausgeführt wird, kommt die fehlermeldung:

'Connection Closed Gracefully'

der compilier gibt keine fehlermeldung raus!

Alterauge 7. Mai 2013 14:57

AW: http request
 
oh, habe was vom quelltext nicht mit angegeben!

sorry!

Delphi-Quellcode:
 // http request
   content := 'type=pocsag&function=a&address=1126026&flags=0&message=hallo';
    if Client.Connected then Client.Disconnect;
     Client.Connect;
      nl := AnsiChar(#13) + AnsiChar(#10);
   request := 'POST /telegramin/alarmgeber/index.xml HTTP/1.1' + nl
   + 'Authorization: Basic jhfhuhjjwerjejghjhewjE=' + nl
   + 'Content-Type: application/x-www-form-urlencoded' + nl
   + 'Host: 192.168.0.110' + nl
   + 'Content-Length: ' + IntToStr(length(content)) + nl
   + 'Expect: 100-continue' + nl
   + 'Connection: Keep-Alive'+ nl + nl
   + content;
 Client.IOHandler.WriteLn(request);
verstehe es nicht? wieso da nix raus geht!
die fehlermeldung: 'connection Closed Gracefully' verstehe ich auch nicht??

Alterauge 11. Mai 2013 19:42

AW: http request
 
Hallo,

so jetzt bekomme ich über Button1 mein Telegramm gesendet! ( 1 x mal)
Benutze die Indy TCPClient Komponente, ein disconnect ist nicht möglich! (ist ja bekannt bei der Indy Komponente)

Was habe ich jetzt noch für eine Möglichkeit, über den Button1 das Telegramm nochmals zu senden?

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
 request, nl, content : string;
 i : integer;
begin
   content := 'type=pocsag&address=1234077&flags=0&function=a&message=hallo';
      nl := AnsiChar(#13) + AnsiChar(#10);
   request := 'POST /telegramin/alarmgeber/input.xml HTTP/1.1' + nl
   + 'Authorization: Basic FtzUjHjUjjJHUJ=' + nl
   + 'Content-Type: application/x-www-form-urlencoded' + nl
   + 'Host: delphi.delphi.de' + nl
   + 'Content-Length: ' + IntToStr(length(content)) + nl
   + 'Expect: 100-continue' + nl
   + 'Connection: Keep-Alive'+ nl + nl
   + content;
 Client.IOHandler.WriteLn(request);
  for I := 1 to 20 do
   Memo1.Lines.Add(Client.IOHandler.ReadLn);
 end

mjustin 12. Mai 2013 10:59

AW: http request
 
Zitat:

Zitat von Alterauge (Beitrag 1215070)
Benutze die Indy TCPClient Komponente, ein disconnect ist nicht möglich! (ist ja bekannt bei der Indy Komponente)

Bei der TIdTCPClient Komponente kann man Disconnect ausführen. Ich bin mir sicher noch nichts gegenteiliges gehört zu haben ...


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:45 Uhr.

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