N
Nuno Magalhaes
I'm doing a "low level" server with sockets and trying to read the HTTP
data from server.
socket.Available at the beginning is 0 and I don't know when an HTTP
page is completly read since socket.Available sometimes is 0 and the
pages don't return the Content-Length field in the HTTP header.
How can I know when an HTTP page is complete? How does Internet
Explorer or Mozilla Firefox implements this procedure?
Any hints? Here's my simple code to retrieve the data after I connect
to the server:
**************************************************
byte[] msg=Encoding.UTF8.GetBytes("GET / HTTP/1.1\n\n");
byte[] bytes=new byte[65536];
int i=socket.Send(msg,0,msg.Length,SocketFlags.None);
MessageBox.Show("Sent "+i.ToString()+" bytes. Available:
"+socket.Available.ToString()+" bytes.");
socket.Receive(bytes,0,socket.Available,SocketFlags.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(bytes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));
data from server.
socket.Available at the beginning is 0 and I don't know when an HTTP
page is completly read since socket.Available sometimes is 0 and the
pages don't return the Content-Length field in the HTTP header.
How can I know when an HTTP page is complete? How does Internet
Explorer or Mozilla Firefox implements this procedure?
Any hints? Here's my simple code to retrieve the data after I connect
to the server:
**************************************************
byte[] msg=Encoding.UTF8.GetBytes("GET / HTTP/1.1\n\n");
byte[] bytes=new byte[65536];
int i=socket.Send(msg,0,msg.Length,SocketFlags.None);
MessageBox.Show("Sent "+i.ToString()+" bytes. Available:
"+socket.Available.ToString()+" bytes.");
socket.Receive(bytes,0,socket.Available,SocketFlags.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(bytes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));