Bugfix, webserver did not handle ? properly

This commit is contained in:
Ziver Koc 2020-11-16 23:58:23 +01:00
parent 69d11634bd
commit 75311f5d74
2 changed files with 8 additions and 2 deletions

View file

@ -125,8 +125,8 @@ public class HttpHeaderParser {
// parse URL and attributes // parse URL and attributes
int paramStartIndex = url.indexOf('?'); int paramStartIndex = url.indexOf('?');
if (paramStartIndex >= 0) { if (paramStartIndex >= 0) {
url = statusLine.substring(0, paramStartIndex); parseURLParameters(header.getURLAttributeMap(), url.substring(paramStartIndex + 1));
parseURLParameters(header.getURLAttributeMap(), statusLine.substring(paramStartIndex + 1)); url = url.substring(0, paramStartIndex);
} }
header.setRequestURL(url.trim()); header.setRequestURL(url.trim());
} }

View file

@ -45,6 +45,12 @@ public class HttpHeaderParserTest {
assertEquals(-1, header.getResponseStatusCode()); assertEquals(-1, header.getResponseStatusCode());
assertEquals(null, header.getResponseStatusString()); assertEquals(null, header.getResponseStatusString());
parser = new HttpHeaderParser("GET /test/page?param=test HTTP/1.1");
header = parser.read();
assertEquals("/test/page", header.getRequestURL());
assertEquals("test", header.getURLAttribute("param"));
parser = new HttpHeaderParser("DESCRIBE http://example.com RTSP/1.0"); parser = new HttpHeaderParser("DESCRIBE http://example.com RTSP/1.0");
header = parser.read(); header = parser.read();