net.lightbody.bmp.util.HttpMessageContents Java Examples

The following examples show how to use net.lightbody.bmp.util.HttpMessageContents. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomRqFilter.java    From carina with Apache License 2.0 6 votes vote down vote up
@Override
public HttpResponse filterRequest(HttpRequest rq, HttpMessageContents contents, HttpMessageInfo messageInfo) {
    if (rewrites.isEmpty()) {
        return null;
    }
    String reqUrl = rq.getUri();
    for (RewriteItem rewriteItem : rewrites) {
        if(reqUrl.matches(rewriteItem.getHost())) {
            // headers rewrite
            LOGGER.debug("Rewrite rule will be applied for host: ".concat(reqUrl));
            rq = applyHeaders(rq, rewriteItem.getHeaders());

            // body rewrite
            String content = contents.getTextContents();
            content.replaceAll(rewriteItem.getRegex(), rewriteItem.getReplacement());
            contents.setTextContents(content);
        }
    }
    
    return null;
}
 
Example #2
Source File: RequestFilterRegistryTest.java    From bobcat with Apache License 2.0 6 votes vote down vote up
@Disabled("TODO - some problems with timing (works in debug mode)")
@Test
public void shouldCallFilterByRegistry() throws IOException {
  // given
  BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
  startProxyServer(browserMobProxy);
  requestFilterRegistry.add(requestFilter);
  browserMobProxy.addRequestFilter(requestFilterRegistry);
  // when
  DesiredCapabilities capabilities = proxyCapabilities(browserMobProxy);
  visitSamplePage(capabilities);
  browserMobProxy.stop();
  // then
  verify(requestFilter, atLeastOnce()).filterRequest(any(HttpRequest.class),
      any(HttpMessageContents.class), any(HttpMessageInfo.class));

}
 
Example #3
Source File: ProxyControllerTest.java    From bobcat with Apache License 2.0 6 votes vote down vote up
@Disabled("TODO - some problems with timing (works in debug mode)")
@Test
public void shouldCallFilterByRegistry() throws IOException {
  // given
  BrowserMobProxy proxy = proxyController.startProxyServer(InetAddress.getLocalHost());
  proxyController.startAnalysis();
  requestFilterRegistry.add(requestFilter);
  // when
  DesiredCapabilities capabilities = proxyCapabilities(proxy);
  visitSamplePage(capabilities);
  proxyController.stopAnalysis();
  proxyController.stopProxyServer();
  // then
  verify(requestFilter, atLeastOnce()).filterRequest(any(HttpRequest.class),
      any(HttpMessageContents.class), any(HttpMessageInfo.class));
}
 
Example #4
Source File: DeviceUtils.java    From AndroidHttpCapture with MIT License 6 votes vote down vote up
public static void changeResponseFilter(SysApplication sysApplication,final List<ResponseFilterRule> ruleList){
    if(ruleList == null){
        Log.e("~~~~","changeResponseFilter ruleList == null!");
        return;
    }

    sysApplication.proxy.addResponseFilter(new ResponseFilter() {
        @Override
        public void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo) {
            for (ResponseFilterRule rule: ruleList) {
                if(rule.getEnable()) {
                    if (contents.isText() && messageInfo.getUrl().contains(rule.getUrl())) {
                        String originContent = contents.getTextContents();
                        if (originContent != null) {
                            contents.setTextContents(contents.getTextContents().replaceAll(
                                    rule.getReplaceRegex(), rule.getReplaceContent()));
                        }
                    }
                }
            }
        }
    });
}
 
Example #5
Source File: RecordRequestFilterTest.java    From bromium with MIT License 6 votes vote down vote up
@Test
public void doesNotAddToQueueIfEncodingIsUnsupporte() throws MalformedURLException, UnsupportedEncodingException {
    HttpRequest httpRequest = mock(HttpRequest.class);
    when(httpRequest.getUri()).thenReturn("blabla" + SUBMIT_EVENT_URL);
    RecordingState recordingState = mock(RecordingState.class);
    Predicate<HttpRequest> httpRequestPredicate = mock(Predicate.class);
    when(httpRequestPredicate.test(httpRequest)).thenReturn(true);
    HttpRequestToTestCaseStepConverter httpRequestToTestCaseStepConverter = mock(HttpRequestToTestCaseStepConverter.class);
    when(httpRequestToTestCaseStepConverter.convert(httpRequest)).thenThrow(new UnsupportedEncodingException());
    EventDetector eventDetector = mock(EventDetector.class);
    when(eventDetector.canDetectPredicate()).thenReturn(httpRequestPredicate);
    when(eventDetector.getConverter()).thenReturn(httpRequestToTestCaseStepConverter);
    List<EventDetector> eventDetectors = Arrays.asList(eventDetector);
    RecordRequestFilter requestFilter = new RecordRequestFilter(recordingState, eventDetectors);
    requestFilter.filterRequest(httpRequest, mock(HttpMessageContents.class), mock(HttpMessageInfo.class));
    verify(recordingState, never()).storeTestCaseStep(anyMap());
}
 
Example #6
Source File: RecordRequestFilterTest.java    From bromium with MIT License 6 votes vote down vote up
@Test
public void doesNotAddToStateIfConverterReturnsEmpty() throws MalformedURLException, UnsupportedEncodingException {
    HttpRequest httpRequest = mock(HttpRequest.class);
    Map<String, String> event = getEvent();
    when(httpRequest.getUri()).thenReturn(SUBMIT_EVENT_URL + "?event=mockEvent&text=mockText");
    Predicate<HttpRequest> httpRequestPredicate = mock(Predicate.class);
    when(httpRequestPredicate.test(httpRequest)).thenReturn(true);
    RecordingState recordingState = mock(RecordingState.class);
    HttpRequestToTestCaseStepConverter httpRequestToTestCaseStepConverter = mock(HttpRequestToTestCaseStepConverter.class);
    when(httpRequestToTestCaseStepConverter.convert(httpRequest)).thenReturn(Optional.empty());
    EventDetector eventDetector = mock(EventDetector.class);
    when(eventDetector.canDetectPredicate()).thenReturn(httpRequestPredicate);
    when(eventDetector.getConverter()).thenReturn(httpRequestToTestCaseStepConverter);
    List<EventDetector> eventDetectors = Arrays.asList(eventDetector);
    RecordRequestFilter requestFilter = new RecordRequestFilter(recordingState, eventDetectors);
    requestFilter.filterRequest(httpRequest, mock(HttpMessageContents.class), mock(HttpMessageInfo.class));

    verify(recordingState, never()).storeTestCaseStep(event);
}
 
Example #7
Source File: RecordRequestFilterTest.java    From bromium with MIT License 6 votes vote down vote up
@Test
public void doesNotAddToQueueIfURLIsMalformed() throws MalformedURLException, UnsupportedEncodingException {
    HttpRequest httpRequest = mock(HttpRequest.class);
    when(httpRequest.getUri()).thenReturn("blabla" + SUBMIT_EVENT_URL);
    RecordingState recordingState = mock(RecordingState.class);
    Predicate<HttpRequest> httpRequestPredicate = mock(Predicate.class);
    when(httpRequestPredicate.test(httpRequest)).thenReturn(true);
    HttpRequestToTestCaseStepConverter httpRequestToTestCaseStepConverter = mock(HttpRequestToTestCaseStepConverter.class);
    when(httpRequestToTestCaseStepConverter.convert(httpRequest)).thenThrow(new MalformedURLException());
    EventDetector eventDetector = mock(EventDetector.class);
    when(eventDetector.canDetectPredicate()).thenReturn(httpRequestPredicate);
    when(eventDetector.getConverter()).thenReturn(httpRequestToTestCaseStepConverter);
    List<EventDetector> eventDetectors = Arrays.asList(eventDetector);
    RecordRequestFilter requestFilter = new RecordRequestFilter(recordingState, eventDetectors);
    requestFilter.filterRequest(httpRequest, mock(HttpMessageContents.class), mock(HttpMessageInfo.class));
    verify(recordingState, never()).storeTestCaseStep(anyMap());
}
 
Example #8
Source File: RecordRequestFilterTest.java    From bromium with MIT License 6 votes vote down vote up
@Test
public void doesNotAddRequestIfNotRequired() {
    HttpRequest httpRequest = mock(HttpRequest.class);
    when(httpRequest.getUri()).thenReturn("http://something/" + "?event=mockEvent&text=mockText");
    RecordingState recordingState = mock(RecordingState.class);
    Predicate<HttpRequest> httpRequestPredicate = mock(Predicate.class);
    when(httpRequestPredicate.test(httpRequest)).thenReturn(false);
    HttpRequestToTestCaseStepConverter httpRequestToTestCaseStepConverter = mock(HttpRequestToTestCaseStepConverter.class);
    EventDetector eventDetector = mock(EventDetector.class);
    when(eventDetector.canDetectPredicate()).thenReturn(httpRequestPredicate);
    when(eventDetector.getConverter()).thenReturn(httpRequestToTestCaseStepConverter);
    List<EventDetector> eventDetectors = Arrays.asList(eventDetector);
    RecordRequestFilter requestFilter = new RecordRequestFilter(recordingState, eventDetectors);
    requestFilter.filterRequest(httpRequest, mock(HttpMessageContents.class), mock(HttpMessageInfo.class));
    verify(recordingState, never()).storeTestCaseStep(anyMap());
}
 
Example #9
Source File: RecordRequestFilterTest.java    From bromium with MIT License 6 votes vote down vote up
@Test
public void addsRequestIfItHasTo() throws MalformedURLException, UnsupportedEncodingException {
    HttpRequest httpRequest = mock(HttpRequest.class, RETURNS_MOCKS);
    Map<String, String> event = getEvent();
    when(httpRequest.getUri()).thenReturn(SUBMIT_EVENT_URL + "?event=mockEvent&text=mockText");
    Predicate<HttpRequest> httpRequestPredicate = mock(Predicate.class);
    when(httpRequestPredicate.test(httpRequest)).thenReturn(true);
    RecordingState recordingState = mock(RecordingState.class);
    HttpRequestToTestCaseStepConverter httpRequestToTestCaseStepConverter = mock(HttpRequestToTestCaseStepConverter.class);
    when(httpRequestToTestCaseStepConverter.convert(httpRequest)).thenReturn(Optional.ofNullable(event));
    EventDetector eventDetector = mock(EventDetector.class);
    when(eventDetector.canDetectPredicate()).thenReturn(httpRequestPredicate);
    when(eventDetector.getConverter()).thenReturn(httpRequestToTestCaseStepConverter);
    List<EventDetector> eventDetectors = Arrays.asList(eventDetector);
    RecordRequestFilter requestFilter = new RecordRequestFilter(recordingState, eventDetectors);
    requestFilter.filterRequest(httpRequest, mock(HttpMessageContents.class), mock(HttpMessageInfo.class));

    verify(recordingState).storeTestCaseStep(event);
}
 
Example #10
Source File: CustomRsFilter.java    From carina with Apache License 2.0 6 votes vote down vote up
@Override
public void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo) {
    if (rewrites.isEmpty()) {
        return;
    }

    String reqUrl = messageInfo.getOriginalUrl();
    for (RewriteItem rewriteItem : rewrites) {
        if (reqUrl.matches(rewriteItem.getHost())) {
            // headers rewrite
            LOGGER.debug("Rewrite rule will be applied for host: ".concat(reqUrl));
            applyHeaders(response, rewriteItem.getHeaders());

            // body rewrite
            String content = contents.getTextContents();
            content.replaceAll(rewriteItem.getRegex(), rewriteItem.getReplacement());
            contents.setTextContents(content);
        }
    }

}
 
Example #11
Source File: RecordRequestFilter.java    From bromium with MIT License 6 votes vote down vote up
@Override
public HttpResponse filterRequest(HttpRequest httpRequest, HttpMessageContents httpMessageContents, HttpMessageInfo httpMessageInfo) {
    for (EventDetector eventDetector: eventDetectors) {
        if (eventDetector.canDetectPredicate().test(httpRequest)) {
            try {
                Optional<Map<String, String>> optionalEvent = eventDetector.getConverter().convert(httpRequest);

                if (optionalEvent.isPresent()) {
                    Map<String, String> event = optionalEvent.get();
                    recordingState.storeTestCaseStep(event);
                    logger.info("Recorded event {}", event);
                }

            } catch (UnsupportedEncodingException | MalformedURLException e) {
                logger.error("Error while trying to convert test case step", e);
            }
        }
    }

    return null;
}
 
Example #12
Source File: ReplayRequestFilter.java    From bromium with MIT License 6 votes vote down vote up
@Override
public HttpResponse filterRequest(HttpRequest httpRequest, HttpMessageContents httpMessageContents, HttpMessageInfo httpMessageInfo) {
    replayingState.addHttpRequestToQueue(httpMessageInfo.getOriginalRequest());
    replayingState.setHttpLock(false);

    for (ConditionsUpdater conditionsUpdater: conditionsUpdaters) {
        if (conditionsUpdater.shouldUpdate().test(httpRequest)) {
            try {
                URL url = new URL(httpRequest.getUri());
                String event = url.getQuery();
                conditionsUpdater.updater().update(replayingState, event);
            } catch (MalformedURLException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    return null;
}
 
Example #13
Source File: ReplayResponseFilter.java    From bromium with MIT License 5 votes vote down vote up
@Override
public void filterResponse(HttpResponse httpResponse, HttpMessageContents httpMessageContents, HttpMessageInfo httpMessageInfo) {
    logger.debug(replayingState.getSubstitutions().toString());

    Optional<String> substitutionsInjectionOptional = getSubstitutionEmittingCode();

    if (shouldInjectJavascriptPredicate.test(httpMessageInfo.getOriginalRequest())) {
        httpMessageContents.setTextContents(injectionCode + substitutionsInjectionOptional.orElse("")  + httpMessageContents.getTextContents());
    }

    replayingState.removeHttpRequestFromQueue(httpMessageInfo.getOriginalRequest());
    replayingState.signalizeIfNoHttpQueriesInQueue();
}
 
Example #14
Source File: RecordResponseFilterTest.java    From bromium with MIT License 5 votes vote down vote up
private void baseTest(boolean predicateReturnValue) {
    HttpRequest httpRequest = mock(HttpRequest.class);
    HttpResponse httpResponse = mock(HttpResponse.class);
    httpMessageContents = mock(HttpMessageContents.class);
    when(httpMessageContents.getTextContents()).thenReturn(htmlContent);
    HttpMessageInfo httpMessageInfo = mock(HttpMessageInfo.class);
    when(httpMessageInfo.getOriginalRequest()).thenReturn(httpRequest);

    Predicate<HttpRequest> predicate = mock(Predicate.class);
    when(predicate.test(httpRequest)).thenReturn(predicateReturnValue);

    RecordResponseFilter recordResponseFilter = new RecordResponseFilter(injectionCode, predicate);
    recordResponseFilter.filterResponse(httpResponse, httpMessageContents, httpMessageInfo);
}
 
Example #15
Source File: BrowsermobProxyUtilsImpl.java    From IridiumApplicationTesting with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void trackErrorResponses(
	final BrowserMobProxy proxy,
	final ProxyDetails<BrowserMobProxy> proxyDetails) {

	proxy.addResponseFilter(new ResponseFilter() {
		@Override
		public void filterResponse(
			final HttpResponse response,
			final HttpMessageContents contents,
			final HttpMessageInfo messageInfo) {

			/*
				Track anything other than a 200 range response
			 */
			if (response.getStatus().code() >= START_HTTP_ERROR
				&& response.getStatus().code() <= END_HTTP_ERROR) {

				synchronized (proxyDetails) {
					final Map<String, Object> properties = proxyDetails.getProperties();
					if (!properties.containsKey(INVALID_REQUESTS)) {
						properties.put(
							INVALID_REQUESTS,
							new ArrayList<HttpMessageInfo>());
					}
					ArrayList.class.cast(properties.get(INVALID_REQUESTS)).add(messageInfo);
					proxyDetails.setProperties(properties);
				}
			}
		}
	});
}
 
Example #16
Source File: RecordThroughTheRecordRequestFilterIT.java    From bromium with MIT License 5 votes vote down vote up
@Override
public void run(RecordingSimulatorModule recordingSimulatorModule) {
    RequestFilter recordRequestFilter = recordingSimulatorModule.getRecordRequestFilter();
    HttpMessageContents httpMessageContents = mock(HttpMessageContents.class);
    HttpMessageInfo httpMessageInfo = mock(HttpMessageInfo.class);

    for (Map<String, String> testCaseStep: expected) {
        String queryString = URLUtils.toQueryString(testCaseStep);
        HttpRequest httpRequest = mock(HttpRequest.class, RETURNS_DEEP_STUBS);
        when(httpRequest.getUri()).thenReturn(SUBMIT_EVENT_URL + queryString);
        when(httpRequest.getMethod()).thenReturn(HttpMethod.GET);
        when(httpRequest.headers().get(ACCEPT)).thenReturn(HTML);
        recordRequestFilter.filterRequest(httpRequest, httpMessageContents, httpMessageInfo);
    }
}
 
Example #17
Source File: PredicateRequestFilter.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
public HttpResponse filterRequest(HttpRequest request,
    HttpMessageContents contents, HttpMessageInfo messageInfo) {
  if (predicate.accepts(request)) {
    synchronized (this) {
      accepted = true;
      notifyAll();
    }
  }
  return null;
}
 
Example #18
Source File: AnalyticsWait.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
public io.netty.handler.codec.http.HttpResponse filterRequest(HttpRequest request,
    HttpMessageContents contents, HttpMessageInfo messageInfo) {
  String path = request.getUri();
  if (path.startsWith(analyticsUriPrefix)) {
    synchronized (this) {
      notifyAll();
    }
  }
  return null;
}
 
Example #19
Source File: RequestFilterRegistry.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
public HttpResponse filterRequest(
    HttpRequest httpRequest, HttpMessageContents httpMessageContents, HttpMessageInfo httpMessageInfo) {
  for (RequestFilter requestFilter : filters) {
    HttpResponse response = requestFilter.filterRequest(httpRequest, httpMessageContents, httpMessageInfo);
    if (response != null) {
      return response;
    }
  }
  return null;
}
 
Example #20
Source File: ProxyStepDefinitions.java    From IridiumApplicationTesting with MIT License 4 votes vote down vote up
/**
 * Apps like life express will often include AWSELB cookies from both the root "/" context and the
 * application "/life-express" context. Supplying both cookies means that requests are sent to a EC2
 * instance that didn't generate the initial session, and so the request fails. This step allows us to
 * remove these duplicated cookies from the request.
 *
 * @param url The regex that matches URLs that should have duplicate AWSELB cookies removed
 */
@When("^I (?:remove|delete) root AWSELB cookie from the request to the URL regex \"(.*?)\"$")
public void stripHeaders(final String url) {
	final Optional<ProxyDetails<?>> proxy =
		State.getFeatureStateForThread().getProxyInterface(BrowsermobProxyUtilsImpl.PROXY_NAME);

	/*
		Get the name of the thread running the test
	 */
	final String threadName = Thread.currentThread().getName();


	proxy
		.flatMap(ProxyDetails::getInterface)
		.map(BrowserMobProxy.class::cast)
		.ifPresent(x -> {
			x.addRequestFilter(new RequestFilter() {
				@Override
				public HttpResponse filterRequest(
					final HttpRequest request,
					final HttpMessageContents contents,
					final HttpMessageInfo messageInfo) {
					if (messageInfo.getOriginalRequest().getUri().matches(url)) {
						final Optional<String> cookies =
							Optional.ofNullable(request.headers().get("Cookie"));

					/*
						Only proceed if we have supplied some cookies
					 */
						if (cookies.isPresent()) {
						/*
							Find the root context cookie
						 */
							final WebDriver webDriver =
								State
									.getThreadDesiredCapabilityMap()
									.getWebDriverForThread(threadName, true);

							final Optional<Cookie> awselb =
								webDriver.manage().getCookies()
									.stream()
									.filter(x -> "AWSELB".equals(x.getName()))
									.filter(x -> "/".equals(x.getPath()))
									.findFirst();

						/*
							If we have a root context cookie,
							remove it from the request
						 */
							if (awselb.isPresent()) {

								LOGGER.info(
									"WEBAPPTESTER-INFO-0002: "
										+ "Removing AWSELB cookie with value {}",
									awselb.get().getValue());

								final String newCookie =
									cookies.get().replaceAll(awselb.get().getName()
											+ "="
											+ awselb.get().getValue() + ";"
											+ "( "
											+ "GMT=; "
											+ "\\d+-\\w+-\\d+=\\d+:\\d+:\\d+;"
											+ ")?",
										"");

								request.headers().set("Cookie", newCookie);
							}

							final int awsElbCookieCount = StringUtils.countMatches(
								request.headers().get("Cookie"),
								"AWSELB");

							if (awsElbCookieCount != 1) {
								LOGGER.info(
									"WEBAPPTESTER-INFO-0003: "
										+ "{} AWSELB cookies found",
									awsElbCookieCount);
							}
						}

					}

					return null;
				}
			});
		});
}
 
Example #21
Source File: RecordResponseFilter.java    From bromium with MIT License 4 votes vote down vote up
@Override
public void filterResponse(HttpResponse httpResponse, HttpMessageContents httpMessageContents, HttpMessageInfo httpMessageInfo) {
    if (shouldInjectJavascriptPredicate.test(httpMessageInfo.getOriginalRequest())) {
        httpMessageContents.setTextContents(injectionCode + httpMessageContents.getTextContents());
    }
}
 
Example #22
Source File: RequestFilter.java    From Dream-Catcher with MIT License 2 votes vote down vote up
/**
 * Implement this method to filter an HTTP request. The HTTP method, URI, headers, etc. are available in the {@code request} parameter,
 * while the contents of the message are available in the {@code contents} parameter. The request can be modified directly, while the
 * contents may be modified using the {@link HttpMessageContents#setTextContents(String)} or {@link HttpMessageContents#setBinaryContents(byte[])}
 * methods. The request can be "short-circuited" by returning a non-null value.
 *
 * @param request The request object, including method, URI, headers, etc. Modifications to the request object will be reflected in the request sent to the server.
 * @param contents The request contents.
 * @param messageInfo Additional information relating to the HTTP message.
 * @return if the return value is non-null, the proxy will suppress the request and send the specified response to the client immediately
 */
HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo);
 
Example #23
Source File: ResponseFilter.java    From Dream-Catcher with MIT License 2 votes vote down vote up
/**
 * Implement this method to filter an HTTP response. The URI, headers, status line, etc. are available in the {@code response} parameter,
 * while the contents of the message are available in the {@code contents} parameter. The response can be modified directly, while the
 * contents may be modified using the {@link HttpMessageContents#setTextContents(String)} or {@link HttpMessageContents#setBinaryContents(byte[])}
 * methods.
 *
 * @param response The response object, including URI, headers, status line, etc. Modifications to the response object will be reflected in the client response.
 * @param contents The response contents.
 * @param messageInfo Additional information relating to the HTTP message.
 */
void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo);
 
Example #24
Source File: RequestFilter.java    From CapturePacket with MIT License 2 votes vote down vote up
/**
 * Implement this method to filter an HTTP request. The HTTP method, URI, headers, etc. are available in the {@code request} parameter,
 * while the contents of the message are available in the {@code contents} parameter. The request can be modified directly, while the
 * contents may be modified using the {@link HttpMessageContents#setTextContents(String)} or {@link HttpMessageContents#setBinaryContents(byte[])}
 * methods. The request can be "short-circuited" by returning a non-null value.
 *
 * @param request The request object, including method, URI, headers, etc. Modifications to the request object will be reflected in the request sent to the server.
 * @param contents The request contents.
 * @param messageInfo Additional information relating to the HTTP message.
 * @return if the return value is non-null, the proxy will suppress the request and send the specified response to the client immediately
 */
HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo);
 
Example #25
Source File: RequestFilter.java    From AndroidHttpCapture with MIT License 2 votes vote down vote up
/**
 * Implement this method to filter an HTTP request. The HTTP method, URI, headers, etc. are available in the {@code request} parameter,
 * while the contents of the message are available in the {@code contents} parameter. The request can be modified directly, while the
 * contents may be modified using the {@link HttpMessageContents#setTextContents(String)} or {@link HttpMessageContents#setBinaryContents(byte[])}
 * methods. The request can be "short-circuited" by returning a non-null value.
 *
 * @param request The request object, including method, URI, headers, etc. Modifications to the request object will be reflected in the request sent to the server.
 * @param contents The request contents.
 * @param messageInfo Additional information relating to the HTTP message.
 * @return if the return value is non-null, the proxy will suppress the request and send the specified response to the client immediately
 */
HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo);
 
Example #26
Source File: ResponseFilter.java    From AndroidHttpCapture with MIT License 2 votes vote down vote up
/**
 * Implement this method to filter an HTTP response. The URI, headers, status line, etc. are available in the {@code response} parameter,
 * while the contents of the message are available in the {@code contents} parameter. The response can be modified directly, while the
 * contents may be modified using the {@link HttpMessageContents#setTextContents(String)} or {@link HttpMessageContents#setBinaryContents(byte[])}
 * methods.
 *
 * @param response The response object, including URI, headers, status line, etc. Modifications to the response object will be reflected in the client response.
 * @param contents The response contents.
 * @param messageInfo Additional information relating to the HTTP message.
 */
void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo);
 
Example #27
Source File: ResponseFilter.java    From CapturePacket with MIT License 2 votes vote down vote up
/**
 * Implement this method to filter an HTTP response. The URI, headers, status line, etc. are available in the {@code response} parameter,
 * while the contents of the message are available in the {@code contents} parameter. The response can be modified directly, while the
 * contents may be modified using the {@link HttpMessageContents#setTextContents(String)} or {@link HttpMessageContents#setBinaryContents(byte[])}
 * methods.
 *
 * @param response The response object, including URI, headers, status line, etc. Modifications to the response object will be reflected in the client response.
 * @param contents The response contents.
 * @param messageInfo Additional information relating to the HTTP message.
 */
void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo);