Mercurial Hosting > luan
comparison src/luan/webserver/Connection.java @ 1147:30d87b7d1d62
webserver - support multipart/form-data
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 01 Feb 2018 22:06:37 -0700 |
parents | 2dda3c92a473 |
children | 49fb4e83484f |
comparison
equal
deleted
inserted
replaced
1146:2dda3c92a473 | 1147:30d87b7d1d62 |
---|---|
74 if( n == -1 ) { | 74 if( n == -1 ) { |
75 throw new IOException("unexpected end of input at "+size); | 75 throw new IOException("unexpected end of input at "+size); |
76 } | 76 } |
77 size += n; | 77 size += n; |
78 } | 78 } |
79 request.body = new String(body); | 79 request.body = body; |
80 //System.out.println(request.body); | 80 //System.out.println(new String(request.body)); |
81 } | 81 } |
82 | 82 |
83 String contentType = (String)request.headers.get("Content-Type"); | 83 String contentType = (String)request.headers.get("Content-Type"); |
84 if( contentType != null ) { | 84 if( contentType != null ) { |
85 if( request.body == null ) { | 85 if( request.body == null ) { |
86 logger.error("body is null"); | 86 logger.error("body is null"); |
87 } else { | 87 } else { |
88 if( "application/x-www-form-urlencoded".equals(contentType) ) { | 88 if( "application/x-www-form-urlencoded".equals(contentType) ) { |
89 parser.parseUrlencoded(); | 89 parser.parseUrlencoded(); |
90 } else if( contentType.startsWith("multipart/form-data;") ) { | |
91 parser.parseMultipart(); | |
90 } else { | 92 } else { |
91 logger.warn("unknown content type: "+contentType); | 93 logger.error("unknown content type: "+contentType); |
92 } | 94 } |
93 } | 95 } |
94 } | 96 } |
95 } | 97 } |
96 | 98 |