Mercurial > hg > ucis.core
comparison Net/HTTP.cs @ 106:a03e6ad0051f
HTTP: Fixed request header handling
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sat, 11 Oct 2014 14:06:32 +0200 |
parents | 04c56f31db37 |
children | 0fc3f42a8555 |
comparison
equal
deleted
inserted
replaced
105:4ba4fd48e1da | 106:a03e6ad0051f |
---|---|
468 } | 468 } |
469 request = RequestAddress.Split(new Char[] { '?' }); | 469 request = RequestAddress.Split(new Char[] { '?' }); |
470 RequestPath = Uri.UnescapeDataString(request[0]); | 470 RequestPath = Uri.UnescapeDataString(request[0]); |
471 RequestQuery = request.Length > 1 ? request[1] : null; | 471 RequestQuery = request.Length > 1 ? request[1] : null; |
472 RequestHeaders = new List<HTTPHeader>(); | 472 RequestHeaders = new List<HTTPHeader>(); |
473 String headerName = null, headerValue = null; | |
473 while (true) { | 474 while (true) { |
474 line = ReadLine(); | 475 line = ReadLine(); |
475 if (line == null) goto SendError400AndClose; | 476 if (line == null) goto SendError400AndClose; |
476 if (line.Length == 0) break; | 477 if (line.Length == 0) break; |
477 request = line.Split(new String[] { ": " }, 2, StringSplitOptions.None); | 478 if (line[0] == ' ' || line[0] == '\t') { |
478 if (request.Length != 2) goto SendError400AndClose; | 479 headerValue += line; |
479 RequestHeaders.Add(new HTTPHeader(request[0], request[1])); | 480 } else { |
480 } | 481 if (headerName != null) RequestHeaders.Add(new HTTPHeader(headerName, (headerValue ?? String.Empty).TrimStart())); |
482 request = line.Split(new Char[] { ':' }, 2, StringSplitOptions.None); | |
483 if (request.Length != 2) goto SendError400AndClose; | |
484 headerName = request[0]; | |
485 headerValue = request[1]; | |
486 } | |
487 } | |
488 if (headerName != null) RequestHeaders.Add(new HTTPHeader(headerName, (headerValue ?? String.Empty).TrimStart())); | |
481 IHTTPContentProvider content = Server.ContentProvider; | 489 IHTTPContentProvider content = Server.ContentProvider; |
482 if (content == null) goto SendError500AndClose; | 490 if (content == null) goto SendError500AndClose; |
483 State = HTTPConnectionState.ProcessingRequest; | 491 State = HTTPConnectionState.ProcessingRequest; |
484 content.ServeRequest(this); | 492 content.ServeRequest(this); |
485 Close(); | 493 Close(); |