Mercurial Hosting > luan
diff src/goodjava/webserver/Connection.java @ 1513:a0a74f5f490a
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 24 May 2020 19:44:58 -0600 |
parents | 471ef3e6a84e |
children | fa066aaa068c |
line wrap: on
line diff
--- a/src/goodjava/webserver/Connection.java Sat May 23 19:01:57 2020 -0600 +++ b/src/goodjava/webserver/Connection.java Sun May 24 19:44:58 2020 -0600 @@ -29,6 +29,7 @@ try { Request request = new Request(); Response response; + String contentType = null; try { { InputStream in = socket.getInputStream(); @@ -83,7 +84,7 @@ //System.out.println(new String(request.body)); } - String contentType = (String)request.headers.get("content-type"); + contentType = (String)request.headers.get("content-type"); if( contentType != null ) { contentType = contentType.toLowerCase(); if( contentType.equals("application/x-www-form-urlencoded") ) { @@ -108,7 +109,10 @@ response = server.handler.handle(request); } catch(ParseException e) { logger.warn("parse error\n"+request.rawHead.trim()+"\n",e); - response = Response.errorResponse(Status.BAD_REQUEST,e.toString()); + String msg = e.toString(); + if( contentType != null ) + msg = "invalid content for content-type " + contentType + "\n" + msg; + response = Response.errorResponse(Status.BAD_REQUEST,msg); } response.headers.put("connection","close"); response.headers.put("content-length",Long.toString(response.body.length));