Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix the BetamaxFilters to deal with aggregated requests.

  • Loading branch information...
commit 678ff6ef8ffb8b6a7e57bb0909734adb61dea0a8 1 parent 3d787ee
@dkowis dkowis authored
View
26 betamax-proxy/src/main/java/co/freeside/betamax/proxy/BetamaxFilters.java
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.util.Map;
import java.util.logging.Logger;
+
import co.freeside.betamax.encoding.*;
import co.freeside.betamax.handler.NonWritableTapeException;
import co.freeside.betamax.message.Response;
@@ -29,6 +30,7 @@
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.*;
import org.littleshoot.proxy.HttpFiltersAdapter;
+
import static co.freeside.betamax.Headers.*;
import static io.netty.buffer.Unpooled.wrappedBuffer;
import static io.netty.handler.codec.http.HttpHeaders.Names.*;
@@ -59,13 +61,13 @@ public HttpResponse requestPre(HttpObject httpObject) {
}
//If we're getting content stick it in there.
- if (httpObject instanceof HttpContent ) {
+ if (httpObject instanceof HttpContent) {
request.append((HttpContent) httpObject);
//If it's the last one, we want to take further steps, like checking to see if we've recorded on it!
- if(httpObject instanceof LastHttpContent) {
+ if (httpObject instanceof LastHttpContent) {
//We will have collected the last of the http Request finally
//And now we're ready to intercept it and do proxy-type-things
- response = onRequestIntercepted((HttpRequest) httpObject).orNull();
+ response = onRequestIntercepted().orNull();
}
}
@@ -77,19 +79,11 @@ public HttpResponse requestPre(HttpObject httpObject) {
@Override
public HttpResponse requestPost(HttpObject httpObject) {
- try {
- if (httpObject instanceof HttpContent) {
- request.append((HttpContent) httpObject);
- }
-
- if (httpObject instanceof HttpRequest) {
- setViaHeader((HttpMessage) httpObject);
- }
-
- return null;
- } catch (IOException e) {
- return createErrorResponse(e);
+ if (httpObject instanceof HttpRequest) {
+ setViaHeader((HttpMessage) httpObject);
}
+
+ return null;
}
@Override
@@ -125,7 +119,7 @@ public void responsePost(HttpObject httpObject) {
}
}
- private Optional<? extends FullHttpResponse> onRequestIntercepted(HttpRequest httpObject) throws IOException {
+ private Optional<? extends FullHttpResponse> onRequestIntercepted() throws IOException {
if (tape == null) {
return Optional.of(new DefaultFullHttpResponse(HTTP_1_1, new HttpResponseStatus(403, "No tape")));
} else if (tape.isReadable() && tape.seek(request)) {
Please sign in to comment.
Something went wrong with that request. Please try again.