Mercurial Hosting > luan
diff src/luan/webserver/RequestParser.java @ 1197:886e14903c1e
better Content-Type handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 27 Feb 2018 01:35:09 -0700 |
parents | bd0420fb3dd0 |
children | 9d3835e88204 |
line wrap: on
line diff
--- a/src/luan/webserver/RequestParser.java Mon Feb 26 21:06:28 2018 -0700 +++ b/src/luan/webserver/RequestParser.java Tue Feb 27 01:35:09 2018 -0700 @@ -2,11 +2,14 @@ import java.util.List; import java.util.ArrayList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import luan.lib.parser.Parser; import luan.lib.parser.ParseException; final class RequestParser { + private static final Logger logger = LoggerFactory.getLogger(Connection.class); private final Request request; private Parser parser; @@ -15,6 +18,10 @@ } void parseUrlencoded() throws ParseException { + if( request.body == null ) { + logger.error("body is null\n"+request.rawHead); + return; + } this.parser = new Parser(Util.toString(request.body)); parseQuery(); require( parser.endOfInput() ); @@ -187,6 +194,10 @@ private static final String contentTypeStart = "multipart/form-data; boundary="; void parseMultipart() throws ParseException { + if( request.body == null ) { + logger.error("body is null\n"+request.rawHead); + return; + } String contentType = (String)request.headers.get("content-type"); if( !contentType.startsWith(contentTypeStart) ) throw new RuntimeException(contentType);