I have a server that sends chunked transfer encoding data . I use InternetReadFile to read the data but InternetReadFile fails with 12004 after reading the first chunk. I used a fiddler ( Wireshark ) to intercept the received data . Wireshark displays the second chunk but InternetReadFile API fails .
Sample Code :
CString totalbuffer ;
While ( 1 )
{
char recv [ 10 ] = '\0' ;
DWORD dwBytesRead = 0 ;
if ( InternetReadFile ( httpSocket.hReq , recv, 10 , &dwBytesRead ) )
{
recv[ dwBytesRead] = '\0' ;
totalbuffer += recv ;
printf ( " received buffer : %s" , recv ) ;
return 1 ;
}
else
{
printf ( " InternetReadFile failed with : %d" , GetLastError ( ) ) ;
return 0 ;
}
};
WireShark displays :
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Thu, 18 Sep 2014 14:16:16 GMT
Server: CHND
3
Ok\n
3
CMD
The client reads only the first 3 bytes chunk . When i try to read the next 3 bytes chunk "CMD" it isn't working.
Kindly help with what necessary changes should the client end do ? or should the server end needs to handle something extra ?