diff src/luan/webserver/RequestParser.java @ 1148:49fb4e83484f

webserver - change headers to lower case
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 04 Feb 2018 17:11:06 -0700
parents 30d87b7d1d62
children bd0420fb3dd0
line wrap: on
line diff
--- a/src/luan/webserver/RequestParser.java	Thu Feb 01 22:06:37 2018 -0700
+++ b/src/luan/webserver/RequestParser.java	Sun Feb 04 17:11:06 2018 -0700
@@ -123,28 +123,16 @@
 	}
 
 	private String parseName() throws ParseException {
-		StringBuilder buf = new StringBuilder();
-		boolean cap = true;
+		int start = parser.currentIndex();
 		require( tokenChar() );
-		do {
-			char c = parser.lastChar();
-			if( c == '-' ) {
-				cap = true;
-			} else if( cap ) {
-				c = Character.toUpperCase(c);
-				cap = false;
-			} else {
-				c = Character.toLowerCase(c);
-			}
-			buf.append(c);
-		} while( tokenChar() );
-		return buf.toString();
+		while( tokenChar() );
+		return parser.textFrom(start).toLowerCase();
 	}
 
-	private String parseValue() {
+	private String parseValue() throws ParseException {
 		int start = parser.currentIndex();
 		while( !testEndOfValue() )
-			parser.anyChar();
+			require( parser.anyChar() );
 		return parser.textFrom(start);
 	}
 
@@ -175,7 +163,7 @@
 
 
 	private void parseCookies() throws ParseException {
-		String text = (String)request.headers.get("Cookie");
+		String text = (String)request.headers.get("cookie");
 		if( text == null )
 			return;
 		this.parser = new Parser(text);
@@ -199,7 +187,7 @@
 	private static final String contentTypeStart = "multipart/form-data; boundary=";
 
 	void parseMultipart() throws ParseException {
-		String contentType = (String)request.headers.get("Content-Type");
+		String contentType = (String)request.headers.get("content-type");
 		if( !contentType.startsWith(contentTypeStart) )
 			throw new RuntimeException(contentType);
 		String boundary = "--"+contentType.substring(contentTypeStart.length());