Mercurial > hg > ucis.core
changeset 106:a03e6ad0051f
HTTP: Fixed request header handling
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sat, 11 Oct 2014 14:06:32 +0200 |
parents | 4ba4fd48e1da |
children | 6be3c9bdb480 |
files | Net/HTTP.cs |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Net/HTTP.cs Sat Oct 11 14:06:11 2014 +0200 +++ b/Net/HTTP.cs Sat Oct 11 14:06:32 2014 +0200 @@ -470,14 +470,22 @@ RequestPath = Uri.UnescapeDataString(request[0]); RequestQuery = request.Length > 1 ? request[1] : null; RequestHeaders = new List<HTTPHeader>(); + String headerName = null, headerValue = null; while (true) { line = ReadLine(); if (line == null) goto SendError400AndClose; if (line.Length == 0) break; - request = line.Split(new String[] { ": " }, 2, StringSplitOptions.None); - if (request.Length != 2) goto SendError400AndClose; - RequestHeaders.Add(new HTTPHeader(request[0], request[1])); + if (line[0] == ' ' || line[0] == '\t') { + headerValue += line; + } else { + if (headerName != null) RequestHeaders.Add(new HTTPHeader(headerName, (headerValue ?? String.Empty).TrimStart())); + request = line.Split(new Char[] { ':' }, 2, StringSplitOptions.None); + if (request.Length != 2) goto SendError400AndClose; + headerName = request[0]; + headerValue = request[1]; + } } + if (headerName != null) RequestHeaders.Add(new HTTPHeader(headerName, (headerValue ?? String.Empty).TrimStart())); IHTTPContentProvider content = Server.ContentProvider; if (content == null) goto SendError500AndClose; State = HTTPConnectionState.ProcessingRequest;