0
httpRequest parseHttpRqt(char *msg) {
	httpRequest rtrn;
	
	
	return rtrn;
}

I was just wondering if anybody could help with parsing a Http Request? I understand that the request is as illustrated below, but how would i turn that into an object containing the code (200/400/404) and the filename? Bearing in mind that I am only concerned with GET requests.

GET /index.html HTTP/1.1\r\n
host: somewebsite.com\r\n
\r\n
4
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by Adak
0

The HTTP format is very well specified (see here). You can simply pull apart the fields you need and ignore the ones you do not.

That aside, I think that wingless provides the best advice: use existing software.

0

If the data is in a file,I'd use fgets() to get each row, then strstr() to look for GET in any row, and sscanf() to save it into the variable that you want.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.