Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bugfix: URL regexp somtimes caused stack overflow exception

bugfix: clients stopped working after first 502
  • Loading branch information...
commit 3405d73fd23508a30c3559f61d1d16d2c4f548df 1 parent c57522c
Krzysztof Kotowicz koto authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 proxy-backend/malaria/MalariaServer.java
6 proxy-backend/malaria/MalariaServer.java
View
@@ -76,7 +76,7 @@ public void serveSocket(Socket client, ServerSocket proxySocket, String hostname
while (!done) {
byte[] buffer = new byte[4096];
int length = clientIn.read(buffer, 0, buffer.length);
- if (new String(buffer, 0, length, "UTF8").equals("HTTP/1.1 502 Not accessible")) {
+ if (new String(buffer, 0, length, "UTF8").startsWith("HTTP/1.1 502 Not accessible")) {
proxyOut.write(buffer, 0, length);
proxyOut.flush();
proxyClient.close();
@@ -121,14 +121,14 @@ public void serveSocket(Socket client, ServerSocket proxySocket, String hostname
private String[] parseRequest(String proxyMessage) {
ArrayList<String> parts = new ArrayList<String>();
- Pattern hostAndAccept = Pattern.compile("(GET|POST) ([^ ]+)(.|[\\s])+Accept: ([\\S]+)(.|[\\s])+");
+ Pattern hostAndAccept = Pattern.compile("^(GET|POST) ([^ ]+).+?Accept: ([\\S]+).*", Pattern.DOTALL);
Matcher m = hostAndAccept.matcher(proxyMessage);
if (!m.matches()) {
return null;
}
parts.add(m.group(1));
parts.add(m.group(2));
- parts.add(m.group(4));
+ parts.add(m.group(3));
String[] headersAndData = proxyMessage.split("\r\n\r\n", 2);
if (headersAndData.length > 1) {
parts.add(headersAndData[1]);
Please sign in to comment.
Something went wrong with that request. Please try again.