diff --git a/src/github/daneren2005/serverproxy/ServerProxy.java b/src/github/daneren2005/serverproxy/ServerProxy.java index a6c353f..e505952 100644 --- a/src/github/daneren2005/serverproxy/ServerProxy.java +++ b/src/github/daneren2005/serverproxy/ServerProxy.java @@ -164,7 +164,10 @@ protected HttpRequest readRequest() { StringTokenizer st = new StringTokenizer(firstLine); if(!st.hasMoreTokens()) { - Log.w(TAG, "Unknown error with no tokens"); + Log.w(TAG, "Unknown request with no tokens"); + return request; + } else if(st.countTokens() < 2) { + Log.w(TAG, "Unknown request with no uri: \"" + firstLine + '"'); return request; } String method = st.nextToken(); @@ -177,7 +180,8 @@ protected HttpRequest readRequest() { String line; while((line = reader.readLine()) != null && !"".equals(line)) { int index = line.indexOf(':'); - if(index != -1) { + // Ignore headers without ':' or where ':' is the last thing in the string + if(index != -1 && (index + 2) < line.length()) { String headerName = line.substring(0, index); String headerValue = line.substring(index + 2); request.addHeader(headerName, headerValue); @@ -185,6 +189,8 @@ protected HttpRequest readRequest() { } } catch(IOException e) { // Don't really care once past first line + } catch(Exception e) { + Log.w(TAG, "Exception reading request", e); } return request;