Mercurial Hosting > luan
diff src/luan/webserver/Connection.java @ 1197:886e14903c1e
better Content-Type handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 27 Feb 2018 01:35:09 -0700 |
parents | 44491798e431 |
children | 9d3835e88204 |
line wrap: on
line diff
--- a/src/luan/webserver/Connection.java Mon Feb 26 21:06:28 2018 -0700 +++ b/src/luan/webserver/Connection.java Tue Feb 27 01:35:09 2018 -0700 @@ -60,7 +60,7 @@ } } String rawHead = new String(a,0,endOfHeader); -//System.out.println(rawHead); + //System.out.println(rawHead); request.rawHead = rawHead; RequestParser parser = new RequestParser(request); parser.parseHead(); @@ -79,21 +79,17 @@ size += n; } request.body = body; -//System.out.println(new String(request.body)); + //System.out.println(new String(request.body)); } String contentType = (String)request.headers.get("content-type"); if( contentType != null ) { - if( request.body == null ) { - logger.error("body is null\n"+request.rawHead); + if( "application/x-www-form-urlencoded".equals(contentType) ) { + parser.parseUrlencoded(); + } else if( contentType.startsWith("multipart/form-data;") ) { + parser.parseMultipart(); } else { - if( "application/x-www-form-urlencoded".equals(contentType) ) { - parser.parseUrlencoded(); - } else if( contentType.startsWith("multipart/form-data;") ) { - parser.parseMultipart(); - } else { - logger.error("unknown content type: "+contentType); - } + logger.warn("unknown content type: "+contentType); } } }