Made HTTP server parsing work when a query like "GET /" comes in that

is missing the HTTP/1.1 version field.
This commit is contained in:
Davis King 2013-09-09 17:47:50 -04:00
parent f67cc88394
commit 2f8a06d531

View File

@ -130,7 +130,7 @@ namespace dlib
buffer.clear();
buffer.reserve(300);
while (in.peek() != delim && in.peek() != EOF && buffer.size() < max)
while (in.peek() != delim && in.peek() != '\n' && in.peek() != EOF && buffer.size() < max)
{
buffer += (char)in.get();
}
@ -141,15 +141,8 @@ namespace dlib
if (buffer.size() == max)
throw http_parse_error("HTTP field from client is too long", 414);
// Make sure the last char is the delim.
if (in.get() != delim)
{
in.setstate(ios::badbit);
buffer.clear();
}
else
{
// Read the remaining delimiters
in.get();
// eat any remaining whitespace
if (delim == ' ')
{
while (in.peek() == ' ')
@ -157,7 +150,6 @@ namespace dlib
}
}
}
}
// ----------------------------------------------------------------------------------------