Search in sources :

Example 1 with HarHeader

use of edu.umass.cs.benchlab.har.HarHeader in project zaproxy by zaproxy.

the class HarUtils method createHttpMessage.

public static HttpMessage createHttpMessage(HarRequest harRequest) throws HttpMalformedHeaderException {
    StringBuilder strBuilderReqHeader = new StringBuilder();
    strBuilderReqHeader.append(harRequest.getMethod()).append(' ').append(harRequest.getUrl()).append(' ').append(harRequest.getHttpVersion()).append("\r\n");
    for (HarHeader harHeader : harRequest.getHeaders().getHeaders()) {
        strBuilderReqHeader.append(harHeader.getName()).append(": ").append(harHeader.getValue()).append("\r\n");
    }
    strBuilderReqHeader.append("\r\n");
    StringBuilder strBuilderReqBody = new StringBuilder();
    final HarPostData harPostData = harRequest.getPostData();
    if (harPostData != null) {
        final String text = harPostData.getText();
        if (text != null && !text.isEmpty()) {
            strBuilderReqBody.append(harRequest.getPostData().getText());
        } else if (harPostData.getParams() != null && !harPostData.getParams().getPostDataParams().isEmpty()) {
            for (HarPostDataParam param : harRequest.getPostData().getParams().getPostDataParams()) {
                if (strBuilderReqBody.length() > 0) {
                    strBuilderReqBody.append('&');
                }
                strBuilderReqBody.append(param.getName()).append('=').append(param.getValue());
            }
        }
    }
    return new HttpMessage(new HttpRequestHeader(strBuilderReqHeader.toString()), new HttpRequestBody(strBuilderReqBody.toString()));
}
Also used : HarPostData(edu.umass.cs.benchlab.har.HarPostData) HttpRequestBody(org.zaproxy.zap.network.HttpRequestBody) HarHeader(edu.umass.cs.benchlab.har.HarHeader) HarQueryString(edu.umass.cs.benchlab.har.HarQueryString) HttpMessage(org.parosproxy.paros.network.HttpMessage) HttpRequestHeader(org.parosproxy.paros.network.HttpRequestHeader) HarPostDataParam(edu.umass.cs.benchlab.har.HarPostDataParam)

Example 2 with HarHeader

use of edu.umass.cs.benchlab.har.HarHeader in project zaproxy by zaproxy.

the class HarUtils method createHarHeaders.

public static HarHeaders createHarHeaders(HttpHeader httpHeader) {
    HarHeaders harHeaders = new HarHeaders();
    List<HttpHeaderField> headers = httpHeader.getHeaders();
    for (HttpHeaderField headerField : headers) {
        harHeaders.addHeader(new HarHeader(headerField.getName(), headerField.getValue()));
    }
    return harHeaders;
}
Also used : HttpHeaderField(org.parosproxy.paros.network.HttpHeaderField) HarHeaders(edu.umass.cs.benchlab.har.HarHeaders) HarHeader(edu.umass.cs.benchlab.har.HarHeader)

Aggregations

HarHeader (edu.umass.cs.benchlab.har.HarHeader)2 HarHeaders (edu.umass.cs.benchlab.har.HarHeaders)1 HarPostData (edu.umass.cs.benchlab.har.HarPostData)1 HarPostDataParam (edu.umass.cs.benchlab.har.HarPostDataParam)1 HarQueryString (edu.umass.cs.benchlab.har.HarQueryString)1 HttpHeaderField (org.parosproxy.paros.network.HttpHeaderField)1 HttpMessage (org.parosproxy.paros.network.HttpMessage)1 HttpRequestHeader (org.parosproxy.paros.network.HttpRequestHeader)1 HttpRequestBody (org.zaproxy.zap.network.HttpRequestBody)1