Hey guys. I have this function:
i need split headers and html.
string simpleGET(string url, string send) {
string headers;
string buffer;
TcpSocket socket;
SocketStream socketSt开发者_如何转开发ream;
if(send is null)
headers = "GET / HTTP/1.1\r\nHost:"~url~"\r\nUConnection:close\r\n\r\n";
else
headers = send;
socket = new TcpSocket(new InternetAddress(url, 80));
socket.send(headers);
socketStream = new SocketStream(socket);
while(!socketStream.eof()){
//here filter, what is headers and the HTML
buffer ~= socketStream.readLine() ~ "\r\n";
}
socketStream.close;
socket.close;
return buffer;
}
thanks,advance.
You should be able to split on two \r\n sequences
string[] parts = std.string.split(buffer, "\r\n\r\n")
parts[0] should contain headers and parts[1] should contain the HTML
精彩评论