Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

some simple bugfixes #1

Merged
merged 1 commit into from

2 participants

@koto

I've started to work on this, hope to integrate MalaRIA with my CORS based clients. could be fun ;)

@koto koto bugfix: URL regexp somtimes caused stack overflow exception
bugfix: clients stopped working after first 502
3405d73
@eoftedal eoftedal merged commit 9bfaec6 into from
@eoftedal
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 12, 2012
  1. @koto

    bugfix: URL regexp somtimes caused stack overflow exception

    koto authored
    bugfix: clients stopped working after first 502
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 proxy-backend/malaria/MalariaServer.java
View
6 proxy-backend/malaria/MalariaServer.java
@@ -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]);
Something went wrong with that request. Please try again.