Mercurial Hosting > luan
diff src/luan/webserver/RequestParser.java @ 1258:e4d7a3114fa8
support "Content-Type: application/json; charset=utf-8"
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 20 Sep 2018 22:11:11 -0600 |
parents | c147e2e877e3 |
children | e8020216dee7 |
line wrap: on
line diff
--- a/src/luan/webserver/RequestParser.java Thu Sep 20 21:04:41 2018 -0600 +++ b/src/luan/webserver/RequestParser.java Thu Sep 20 22:11:11 2018 -0600 @@ -264,4 +264,17 @@ } } + // improve later + void parseJson() throws UnsupportedEncodingException { + if( request.body == null ) { + logger.warn("body is null\n"+request.rawHead); + return; + } + String contentType = (String)request.headers.get("content-type"); + if( !contentType.equals("application/json; charset=utf-8") ) + throw new RuntimeException(contentType); + String value = new String(request.body,"utf-8"); + Util.add(request.parameters,"json",value); + } + }