net.lightbody.bmp.core.har.HarNameValuePair Java Examples

The following examples show how to use net.lightbody.bmp.core.har.HarNameValuePair. 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: HarCaptureFilter.java    From CapturePacket with MIT License 6 votes vote down vote up
protected void captureQueryParameters(HttpRequest httpRequest) {
    // capture query parameters. it is safe to assume the query string is UTF-8, since it "should" be in US-ASCII (a subset of UTF-8),
    // but sometimes does include UTF-8 characters.
    QueryStringDecoder queryStringDecoder = new QueryStringDecoder(httpRequest.getUri(), StandardCharsets.UTF_8);

    try {
        for (Map.Entry<String, List<String>> entry : queryStringDecoder.parameters().entrySet()) {
            for (String value : entry.getValue()) {
                harEntry.getRequest().getQueryString().add(new HarNameValuePair(entry.getKey(), value));
            }
        }
    } catch (IllegalArgumentException e) {
        // QueryStringDecoder will throw an IllegalArgumentException if it cannot interpret a query string. rather than cause the entire request to
        // fail by propagating the exception, simply skip the query parameter capture.
        harEntry.setComment("Unable to decode query parameters on URI: " + httpRequest.getUri());
        log.info("Unable to decode query parameters on URI: " + httpRequest.getUri(), e);
    }
}
 
Example #2
Source File: ContentTabHolder.java    From CapturePacket with MIT License 6 votes vote down vote up
private List<? extends INameValue> getOverViewList(HarEntry harEntry) {
    ArrayList<HarNameValuePair> pairs = new ArrayList<>();
    HarRequest harRequest = harEntry.getRequest();
    HarResponse harResponse = harEntry.getResponse();
    if (harRequest != null) {
        String url = harRequest.getUrl();
        try {
            url = URLDecoder.decode(url, "utf-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        pairs.add(new HarNameValuePair("URL", url));

        pairs.add(new HarNameValuePair("Method", harRequest.getMethod()));
    }
    if (harResponse != null) {
        pairs.add(new HarNameValuePair("Code", harResponse.getStatus() + ""));
        pairs.add(new HarNameValuePair("Size", harResponse.getBodySize() + "Bytes"));
    }
    pairs.add(new HarNameValuePair("TotalTime", harEntry.getTime() + "ms"));
    return pairs;
}
 
Example #3
Source File: HarCaptureFilter.java    From AndroidHttpCapture with MIT License 6 votes vote down vote up
protected void captureQueryParameters(HttpRequest httpRequest) {
    // capture query parameters. it is safe to assume the query string is UTF-8, since it "should" be in US-ASCII (a subset of UTF-8),
    // but sometimes does include UTF-8 characters.
    QueryStringDecoder queryStringDecoder = new QueryStringDecoder(httpRequest.getUri(), StandardCharsets.UTF_8);

    try {
        for (Map.Entry<String, List<String>> entry : queryStringDecoder.parameters().entrySet()) {
            for (String value : entry.getValue()) {
                harEntry.getRequest().getQueryString().add(new HarNameValuePair(entry.getKey(), value));
            }
        }
    } catch (IllegalArgumentException e) {
        // QueryStringDecoder will throw an IllegalArgumentException if it cannot interpret a query string. rather than cause the entire request to
        // fail by propagating the exception, simply skip the query parameter capture.
        harEntry.setComment("Unable to decode query parameters on URI: " + httpRequest.getUri());
        log.info("Unable to decode query parameters on URI: " + httpRequest.getUri(), e);
    }
}
 
Example #4
Source File: HeaderExpandAdapter.java    From CapturePacket with MIT License 5 votes vote down vote up
@Override
public List<HarNameValuePair> getChild(int groupPosition, int childPosition) {
    if (groupPosition == 0) {
       return mRequestHeader;
    } else if (groupPosition == 1){
        return mResponseHeader;
    }
    return null;
}
 
Example #5
Source File: QueryParametersPredicate.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
public boolean apply(HarEntry input) {
  List<HarNameValuePair> inputParams = input.getRequest().getQueryString();
  for (Entry<String, String> expectedParam : expectedParams.entrySet()) {
    if (!isPresent(expectedParam.getKey(), expectedParam.getValue(), inputParams)) {
      return false;
    }
  }
  return true;
}
 
Example #6
Source File: QueryParametersPredicate.java    From bobcat with Apache License 2.0 5 votes vote down vote up
private boolean isPresent(String key, String value, List<HarNameValuePair> params) {
  for (HarNameValuePair param : params) {
    if (param.getName().equals(key) && param.getValue().equals(value)) {
      return true;
    }
  }
  return false;
}
 
Example #7
Source File: HarCaptureFilter.java    From Dream-Catcher with MIT License 5 votes vote down vote up
protected void captureHeaders(HttpHeaders headers) {
    Log.e("InnerHandle", "captureHeaders " + harEntry.getId());
    for (Map.Entry<String, String> header : headers.entries()) {
        harRequest.getRequest().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
        harRequest.addHeader(header.getKey(), header.getValue());
    }
}
 
Example #8
Source File: HarCaptureFilter.java    From Dream-Catcher with MIT License 5 votes vote down vote up
protected void captureResponseHeaders(HttpResponse httpResponse) {
    Log.e("InnerHandle", "captureResponseHeaders " + harEntry.getId());
    HttpHeaders headers = httpResponse.headers();
    for (Map.Entry<String, String> header : headers.entries()) {
        harResponse.getResponse().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
        harResponse.addHeader(header.getKey(), header.getValue());
    }
}
 
Example #9
Source File: HarCaptureFilter.java    From CapturePacket with MIT License 4 votes vote down vote up
protected void captureHeaders(HttpHeaders headers) {
    for (Map.Entry<String, String> header : headers.entries()) {
        harEntry.getRequest().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
    }
}
 
Example #10
Source File: HarCaptureFilter.java    From CapturePacket with MIT License 4 votes vote down vote up
protected void captureResponseHeaders(HttpResponse httpResponse) {
    HttpHeaders headers = httpResponse.headers();
    for (Map.Entry<String, String> header : headers.entries()) {
        harEntry.getResponse().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
    }
}
 
Example #11
Source File: HeaderExpandAdapter.java    From CapturePacket with MIT License 4 votes vote down vote up
public void setHeaders(List<HarNameValuePair> requestHeader,List<HarNameValuePair> responseHeader) {
    mRequestHeader = requestHeader;
    mResponseHeader = responseHeader;
    notifyDataSetChanged();

}
 
Example #12
Source File: HarCaptureFilter.java    From AndroidHttpCapture with MIT License 4 votes vote down vote up
protected void captureHeaders(HttpHeaders headers) {
    for (Map.Entry<String, String> header : headers.entries()) {
        harEntry.getRequest().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
    }
}
 
Example #13
Source File: HarCaptureFilter.java    From AndroidHttpCapture with MIT License 4 votes vote down vote up
protected void captureResponseHeaders(HttpResponse httpResponse) {
    HttpHeaders headers = httpResponse.headers();
    for (Map.Entry<String, String> header : headers.entries()) {
        harEntry.getResponse().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
    }
}