Mercurial Hosting > luan
diff src/goodjava/webserver/Connection.java @ 1463:fb003c4003dd
better application/json handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 30 Mar 2020 18:31:18 -0600 |
parents | 27efb1fcbcb5 |
children | 471ef3e6a84e |
line wrap: on
line diff
--- a/src/goodjava/webserver/Connection.java Sun Mar 29 09:55:59 2020 -0600 +++ b/src/goodjava/webserver/Connection.java Mon Mar 30 18:31:18 2020 -0600 @@ -85,14 +85,16 @@ String contentType = (String)request.headers.get("content-type"); if( contentType != null ) { contentType = contentType.toLowerCase(); - if( "application/x-www-form-urlencoded".equals(contentType) ) { + if( contentType.equals("application/x-www-form-urlencoded") ) { parser.parseUrlencoded(null); - } else if( "application/x-www-form-urlencoded; charset=utf-8".equals(contentType) ) { + } else if( contentType.equals("application/x-www-form-urlencoded; charset=utf-8") ) { parser.parseUrlencoded("utf-8"); } else if( contentType.startsWith("multipart/form-data;") ) { parser.parseMultipart(); + } else if( contentType.equals("application/json") ) { + parser.parseJson(null); } else if( contentType.equals("application/json; charset=utf-8") ) { - parser.parseJson(); + parser.parseJson("utf-8"); } else { logger.info("unknown request content-type: "+contentType); }