I’m coding a httpserver and I’m stuck at parsing GET requests.
How would I parse a char buffer with something like
GET /images/logo.png HTTP/1.1
So that I only get the path and file extension but ignore the other parts?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t say specifically say what sort of storage this string is in – simple char* or some string class.
So, in general, you could either do it the rather simple and dirty way, by splitting the string on the space character, and taking the second or middle section. Or, a better approach would be to get familiar with Regular Expressions. C++ has several regex libraries – Boost is well regarded.