HTTP/1.0 408 Request Timeout
Server: thttpd/2.19-MX Jul 5 2010
Content-type: text/html
Date: Wed, 10 Nov 2010 01:10:05 GMT
Last-modified: Wed, 10 Nov 2010 01:10:05 GMT
Accept-Ranges: bytes
Connection: close
<HTML><HEAD><TITLE>408 Request Timeout</TITLE></HEAD>
408 Request Timeout
No request appeared within a reasonable time period.
<HR>
thttpd/2.19-MX Jul 5 2010</HTML>
void __fastcall TClient::SendClick(TObject *Sender)
{
if( ClientSocket1->Active )
ClientSocket1->Socket->SendText(EdSend->Text);
else {
LbCState->Caption = " Serveur Client à L'arret ";
LbCState->Color=clRed;
LbCState->Font->Color=clWhite;
BnConnect->Caption= "Activer";
}
}
void __fastcall TClient::ClientSocket1Read(TObject *Sender,
TCustomWinSocket *Socket)
{
// EdReceive->Text=ClientSocket1->Socket->ReceiveText();
AnsiString Data;
Data.SetLength(Socket->ReceiveLength());
Socket->ReceiveBuf(Data.c_str(),Socket->ReceiveLength());
ShowMessage(Socket->RemoteHost+": "+Data);
Memo1->Text=Data; //
}
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ScktComp, StdCtrls, StrUtils, ExtCtrls, Jpeg, Buttons; type TForm1 = class(TForm) btnGo: TButton; memResponseHeader: TMemo; imgResult: TImage; socMain: TClientSocket; procedure btnGoClick(Sender: TObject); procedure socMainRead(Sender: TObject; Socket: TCustomWinSocket); procedure socMainConnect(Sender: TObject; Socket: TCustomWinSocket); procedure FormCreate(Sender: TObject); procedure socMainError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); private _lpResponse: String; _bReadingHeader: Boolean; _nContentLength: Integer; _lpContentStream: TMemoryStream; function GetContentLength(lpHeader: String): Integer; function CheckResponse(lpHeader: String): Boolean; procedure DisplayImage(); procedure CleanUp(); public { Déclarations publiques } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btnGoClick(Sender: TObject); begin btnGo.Enabled:= False; _lpResponse:= ''; _bReadingHeader:= True; _lpContentStream:= nil; socMain.Open; end; procedure TForm1.socMainError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); begin if ErrorEvent = eeGeneral then ShowMessage('Erreur inattendu'); if ErrorEvent = eeSend then ShowMessage('Erreur d''écriture sur la connexion socket'); if ErrorEvent = eeReceive then ShowMessage('Erreur de lecture sur la connexion socket'); if ErrorEvent = eeConnect then ShowMessage('Une demande de connexion déjà acceptée n''a pas pu être achevée'); if ErrorEvent = eeDisconnect then ShowMessage('Erreur de fermeture d''une connexion'); if ErrorEvent = eeAccept then ShowMessage('Erreur d''acceptation d''une demande de connexion cliente'); CleanUp; end; function TForm1.GetContentLength(lpHeader: String): Integer; var nContentLengthPos: Integer; lpContentLengthString: String; nEndOfLinePos: Integer; begin Result:= 0; // Récupération du début le Content-Length nContentLengthPos:= Pos('Content-Length:', lpHeader); if nContentLengthPos = 0 then Exit; lpContentLengthString:= MidStr(lpHeader, nContentLengthPos, High(Integer)); // Troncature de ce qui se trouve après le Content-Length nEndOfLinePos:= Pos(#13#10, lpContentLengthString); if nEndOfLinePos = 0 then nEndOfLinePos:= Pos(#10, lpContentLengthString); lpContentLengthString:= LeftStr(lpContentLengthString, nEndOfLinePos - 1); // Récupération de la valeur lpContentLengthString:= StringReplace(lpContentLengthString, 'Content-Length:', '', [rfReplaceAll, rfIgnoreCase]); lpContentLengthString:= Trim(lpContentLengthString); Result:= StrToInt(lpContentLengthString); end; function TForm1.CheckResponse(lpHeader: String): Boolean; var nEndOfLinePos: Integer; lpStatus: String; begin nEndOfLinePos:= Pos(#13#10, lpHeader); if nEndOfLinePos = 0 then nEndOfLinePos:= Pos(#10, lpHeader); lpStatus:= LeftStr(lpHeader, nEndOfLinePos - 1); Result:= Pos('200 OK', lpStatus) <> 0; end; procedure TForm1.DisplayImage(); var lpJpg: TJPEGImage; begin lpJpg:= TJPEGImage.Create; _lpContentStream.Position:= 0; lpJpg.LoadFromStream(_lpContentStream); imgResult.Picture.Assign(lpJpg); lpJpg.Free; CleanUp; end; procedure TForm1.CleanUp(); begin FreeAndNil(_lpContentStream); socMain.Close; btnGo.Enabled:= True; end; procedure TForm1.socMainRead(Sender: TObject; Socket: TCustomWinSocket); var nEndOfHeader: Integer; nEndOfHeaderSize: Integer; lpReceivedText: String; lpHeader: String; lpContent: ^Char; nReadContent: Integer; nReceived: Integer; begin nReceived:= Socket.ReceiveLength; lpReceivedText:= Socket.ReceiveText; // Si le header n'a pas encore été complètement lu if _bReadingHeader then begin _lpResponse:= _lpResponse + lpReceivedText; // Recherche de \r\n\r\n nEndOfHeaderSize:= 4; nEndOfHeader:= Pos(#13#10#13#10, _lpResponse); // Recherche de \n\n if nEndOfHeader = 0 then begin nEndOfHeaderSize:= 2; nEndOfHeader:= Pos(#10#10, _lpResponse); end; // Si au moins tout le header est arrivé if nEndOfHeader <> 0 then begin _bReadingHeader:= False; // Extraction du header lpHeader:= LeftStr(_lpResponse, nEndOfHeader + nEndOfHeaderSize - 1); memResponseHeader.Text:= lpHeader; // Vérification que c'est bien une réponse 200 OK if not CheckResponse(lpHeader) then begin ShowMessage('Mauvais status code'); Exit; end; // Rcupération de la taille du content, donc de la jpg _nContentLength:= GetContentLength(lpHeader); lpContent:= @_lpResponse[nEndOfHeader + nEndOfHeaderSize]; nReadContent:= Length(_lpResponse) - Length(lpHeader); _lpContentStream:= TMemoryStream.Create; _lpContentStream.Write(lpContent^, nReadContent); end; end else _lpContentStream.Write(PChar(lpReceivedText)^, nReceived); // On affiche l'image quand on a reçu tout le content if _lpContentStream <> nil then if _lpContentStream.Position = _nContentLength then DisplayImage; end; procedure TForm1.socMainConnect(Sender: TObject; Socket: TCustomWinSocket); begin socMain.Socket.SendText('GET http://www.trinum.com/ibox/ftpcam/rosiere_traversette.jpg HTTP/1.0' + sLineBreak + sLineBreak); end; procedure TForm1.FormCreate(Sender: TObject); begin socMain.Host:= 'www.trinum.com'; socMain.Port:= 80; end; end.
GET /record/current.jpg HTTP/1.0";
Accept image/jpeg;
(cr/lf)
void __fastcall TClient::ClientSocket1Read(TObject *Sender,
TCustomWinSocket *Socket)
{
// EdReceive->Text=ClientSocket1->Socket->ReceiveText();
AnsiString Data;
Data.SetLength(Socket->ReceiveLength());
Socket->ReceiveBuf(Data.c_str(),Socket->ReceiveLength());
//ShowMessage(Socket->RemoteHost+": "+Data); // alternative
char* MSG = new char[ Data.Length() + 1];
strcpy( MSG, Data.c_str() );
Display(MSG, strlen(MSG));
delete MSG;
MemoText->Lines->Add("");
MemoText->Lines->Add("Recu :");
MemoText->Lines->Add(Data);
}
void __fastcall TClient::Display(char* pBuffer, int BLength)
{
int BytesRead;
String linebuff;
String texte;
String hex;
/* linebuff type
/* 00000: 43 56 53 0a 4d 61 6b 65 66 69 6c 65 0a 64 65 66 : CVS.Makefile.def */
// pszBuffer = new char[FileLength+1];
// construction des lignes converties en hexa décimal
int i=0;
while ( i < BLength )
{
texte = "";
linebuff = " "; // chaine début de ligne
//string adrhex="0123456"; // adresse 1er octets de la ligne
//itoa(i, adrhex, 10); // conversion en char et mise en forme
String adrhex = IntToStr(i);
if (i<10) linebuff = linebuff + "00000" + adrhex;
else {
if (i<100) linebuff = linebuff + "0000" + adrhex;
else {
if (i<1000) linebuff = linebuff + "000" + adrhex;
else {
if (i<10000) linebuff = linebuff + "00" + adrhex;
else {
if (i<100000) linebuff = linebuff + "0" + adrhex;
else { linebuff = linebuff + adrhex; }
} } } }
linebuff = linebuff + " : ";
for (int j=0; j < 16 ; ++j) // lignes de 16 caracteres
{
hex = IntToHex((int)pBuffer[i],2); // conversion octets en hexa
linebuff = linebuff + " " + hex;
// transfert du texte
if ( (pBuffer[i] & 0x80) == 0 && isprint(pBuffer[i]) )
texte= texte+ pBuffer[i]; // texte[j]= pszBuffer[i];
else texte= texte+ '.';
i++; // caractere suivant
if (i >= BLength) { j=16; } // fin de traitement
}
linebuff = linebuff + " : " + texte; // ajout séparation + caracteres
MemoHex->Lines->Add(linebuff);
}
}
// *********************************
--------
Message Envoyé :
GET /record/current.jpg HTTP/1.0
Accept image/jpeg
Recu :
HTTP/1.1 200 OK
Via: 1.1 MYCO-SRV
Connection: close
Proxy-Connection: close
Content-length: 34873
Date: Fri, 19 Nov 2010 19:17:48 GMT
Content-type: image/jpeg
Server: thttpd/2.19-MX Jul 5 2010
Last-modified: Fri, 19 Nov 2010 19:17:48 GMT
Accept-Ranges: bytes
ÿØÿà
Recu :
Rm«
ŒS
üÍë@ïM+ÍNWÐQ.ëëHHù±Þ'€íŠ"®yŠz
Recu :
3üî²}ré].Ž?âM¶ô#\ŒMæÙ£÷Àþ=?'®«FçI^
..... etc
000000 : 47 45 54 20 2F 72 65 63 6F 72 64 2F 63 75 72 72 . GET /record/curr
000016 : 65 6E 74 2E 6A 70 67 20 48 54 54 50 2F 31 2E 30 . ent.jpg HTTP/1.0
000032 : 0D 0A . ..
000000 : 41 63 63 65 70 74 20 69 6D 61 67 65 2F 6A 70 65 . Accept image/jpe
000016 : 67 0D 0A . g..
000000 : 0D 0A . ..
000000 : 48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D . HTTP/1.1 200 OK.
000016 : 0A 56 69 61 3A 20 31 2E 31 20 4D 59 43 4F 2D 53 . .Via: 1.1 MYCO-S
000032 : 52 56 0D 0A 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 . RV..Connection:
000048 : 63 6C 6F 73 65 0D 0A 50 72 6F 78 79 2D 43 6F 6E . close..Proxy-Con
000064 : 6E 65 63 74 69 6F 6E 3A 20 63 6C 6F 73 65 0D 0A . nection: close..
000080 : 43 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 . Content-length:
000096 : 33 34 38 37 33 0D 0A 44 61 74 65 3A 20 46 72 69 . 34873..Date: Fri
000112 : 2C 20 31 39 20 4E 6F 76 20 32 30 31 30 20 31 39 . , 19 Nov 2010 19
000128 : 3A 31 37 3A 34 38 20 47 4D 54 0D 0A 43 6F 6E 74 . :17:48 GMT..Cont
000144 : 65 6E 74 2D 74 79 70 65 3A 20 69 6D 61 67 65 2F . ent-type: image/
000160 : 6A 70 65 67 0D 0A 53 65 72 76 65 72 3A 20 74 68 . jpeg..Server: th
000176 : 74 74 70 64 2F 32 2E 31 39 2D 4D 58 20 4A 75 6C . ttpd/2.19-MX Jul
000192 : 20 20 35 20 32 30 31 30 0D 0A 4C 61 73 74 2D 6D . 5 2010..Last-m
000208 : 6F 64 69 66 69 65 64 3A 20 46 72 69 2C 20 31 39 . odified: Fri, 19
000224 : 20 4E 6F 76 20 32 30 31 30 20 31 39 3A 31 37 3A . Nov 2010 19:17:
000240 : 34 38 20 47 4D 54 0D 0A 41 63 63 65 70 74 2D 52 . 48 GMT..Accept-R
000256 : 61 6E 67 65 73 3A 20 62 79 74 65 73 0D 0A 0D 0A . anges: bytes....
000272 : FFFFFFFF FFFFFFD8 FFFFFFFF FFFFFFE0 . ....
000000 : 52 6D FFFFFFAB 0C FFFFFFBC 53 0A FFFFFFFC FFFFFFCD FFFFFFEB 40 10 14 FFFFFFEF 4D 2B . Rm...S....@...M+
000016 : FFFFFFCD 4E 57 07 FFFFFFD0 01 51 FFFFFF95 FFFFFFEB FFFFFFEB 48 08 48 FFFFFFF9 FFFFFFB1 FFFFFFDE . .NW...Q...H.H...
000032 : FFFFFF91 FFFFFF80 FFFFFFED FFFFFF8A FFFFFF94 FFFFFFAE 79 FFFFFFA6 FFFFFF8F 7A . ......y..z
000000 : 1B 33 FFFFFFFC FFFFFFEE FFFFFFB2 7F 7D 72 7F 03 FFFFFF8F FFFFFFE9 5D 2E FFFFFF8E 3F . .3....}r....]..?
000016 : FFFFFFE2 4D 0F FFFFFFB6 7F FFFFFFF4 23 5C FFFFFFBC 4D FFFFFFE6 FFFFFFD9 FFFFFFA3 FFFFFFF7 0E FFFFFFC0 . .M....#\.M......
000032 : FFFFFFFE 3D 3F FFFFFF91 FFFFFFAE FFFFFFAB 46 FFFFFFE7 49 FFFFFF88 7B 37 FFFFFFFE FFFFFF84 69 75 . .=?...F.I.{7..iu
000048 : 1F 42 72 2B FFFFFF9C FFFFFFF1 17 FFFFFF83 6D FFFFFFB5 FFFFFFA6 6B FFFFFF9B 76 16 FFFFFFD7 . .Br+....m..k.v..
000064 : FFFFFFBF FFFFFFDF 03 FFFFFFE5 FFFFFF93 FFFFFFFD FFFFFFE1 FFFFFFFD 7F FFFFFF9D 75 02 32 79 FFFFFFC1 FFFFFFA5 . ..........u.2y..
000080 : 28 14 1C FFFFFF95 FFFFFFFE 74 58 0F 15 FFFFFFD4 FFFFFFF4 2D 47 48 FFFFFF90 FFFFFF8B . (....tX....-GH..
000096 : FFFFFFDB 56 45 FFFFFFCE 04 FFFFFF8A 32 FFFFFF87 FFFFFFE8 47 FFFFFFF5 FFFFFFE6 FFFFFFAA 22 FFFFFF9E FFFFFFFC . .VE...2..G..."..
000112 : 57 FFFFFFB5 FFFFFFC9 33 0C FFFFFFAE FFFFFFC6 70 78 23 1C 1A FFFFFFC7 FFFFFFB9 FFFFFFD0 FFFFFFF4 . W..3...px#......
000128 : FFFFFFCB FFFFFFA6 FFFFFFCB FFFFFFE8 FFFFFFD6 FFFFFFCA FFFFFFC7 FFFFFFF8 FFFFFF90 14 3F FFFFFFF8 FFFFFFE9 14 FFFFFFAC 2B . ..........?....+
000144 : 1E 6B 0A FFFFFF82 40 39 3E FFFFFFC0 56 FFFFFFAD FFFFFFA2 FFFFFFEC 23 76 FFFFFFD4 1E . .k..@9>.V...#v..
000160 : FFFFFFAE 6B FFFFFFAE 1E 16 FFFFFFD3 3F FFFFFFE7 FFFFFFCA 4C 7A 09 FFFFFF9C 0F FFFFFFE7 5A . .k....?..Lz....Z
000176 : 16 7A 45 FFFFFF85 FFFFFF9B 06 FFFFFF83 4C FFFFFF85 58 74 66 5D FFFFFFEC 3F 13 . .zE....L.Xtf].?.
000192 : FFFFFF93 47 29 0E 17 32 FFFFFFB4 2B 07 FFFFFFB8 FFFFFF91 65 FFFFFFDB 24 FFFFFF8B FFFFFFC7 . .G)..2.+...e.$..
000208 : 38 FFFFFFDB 1F 1D 31 FFFFFFEA 79 FFFFFFEB FFFFFFC9 FFFFFFAE FFFFFFC2 18 FFFFFF84 23 FFFFFFE4 FFFFFF8C . 8...1.y......#..
000224 : 6E FFFFFFEE FFFFFFCD FFFFFFCD 10 33 37 FFFFFFDE 5C 54 FFFFFFFD 28 4A FFFFFFC2 FFFFFF8D 28 . n....37.\T.(J..(
000240 : FFFFFFC5 FFFFFFDC 6E 24 6E FFFFFFAE 40 FFFFFFF4 1C 52 FFFFFF88 FFFFFF94 73 FFFFFFC1 3E FFFFFFA7 . ..n$n.@..R..s.>.
000256 : FFFFFF9A 75 15 46 FFFFFFA1 FFFFFFC5 2E 69 29 FFFFFF92 FFFFFFCC FFFFFF90 FFFFFF8F FFFFFF9D FFFFFFB9 FFFFFFFE . .u.F...i).......
000272 : FFFFFFE8 FFFFFFEB 48 09 2A FFFFFFBC FFFFFFD7 07 77 FFFFFF97 10 25 FFFFFFB3 FFFFFFD4 54 12 . ..H.*...w..%..T.
000288 : 5E FFFFFFBB 7D FFFFFFCC 20 FFFFFFFD 69 2D FFFFFFE4 FFFFFFD9 FFFFFF96 FFFFFFCF 3D 73 40 22 . ^.}. .i-....=s@"
000304 : FFFFFFC2 5C FFFFFFB2 . .\.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question