Permalink
Browse files

Don't attempt to intercept the request...

...Until we've received the ENTIRE request
  • Loading branch information...
1 parent 4921308 commit 6d7e73daecc3ed176414170f426c497168e78f30 David Kowis committed Nov 20, 2013
Showing with 12 additions and 1 deletion.
  1. +12 −1 betamax-proxy/src/main/java/co/freeside/betamax/proxy/BetamaxFilters.java
@@ -56,8 +56,19 @@ public HttpResponse requestPre(HttpObject httpObject) {
HttpResponse response = null;
if (httpObject instanceof HttpRequest) {
request.copyHeaders((HttpMessage) httpObject);
- response = onRequestIntercepted((HttpRequest) httpObject).orNull();
}
+
+ //If we're getting content stick it in there.
+ 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) {
+ //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();
+ }
+ }
+
return response;
} catch (IOException e) {
return createErrorResponse(e);

0 comments on commit 6d7e73d

Please sign in to comment.