use of org.parosproxy.paros.network.HttpHeaderField in project zaproxy by zaproxy.
the class VariantHeader method setMessage.
/**
* @throws IllegalArgumentException if {@code message} is {@code null}.
*/
@Override
public void setMessage(HttpMessage message) {
if (message == null) {
throw new IllegalArgumentException("Parameter message must not be null.");
}
ArrayList<NameValuePair> extractedParameters = new ArrayList<>();
List<HttpHeaderField> httpHeaders = message.getRequestHeader().getHeaders();
for (HttpHeaderField header : httpHeaders) {
if (!NON_INJECTABLE_HEADERS.contains(header.getName().toLowerCase(Locale.ROOT))) {
extractedParameters.add(new NameValuePair(NameValuePair.TYPE_HEADER, header.getName(), header.getValue(), extractedParameters.size()));
}
}
if (extractedParameters.isEmpty()) {
params = Collections.emptyList();
} else {
extractedParameters.trimToSize();
params = Collections.unmodifiableList(extractedParameters);
}
}
use of org.parosproxy.paros.network.HttpHeaderField 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;
}
use of org.parosproxy.paros.network.HttpHeaderField in project zaproxy by zaproxy.
the class VariantHeaderUnitTest method containsHeader.
private static Matcher<HttpMessage> containsHeader(final String name, final String value) {
return new BaseMatcher<HttpMessage>() {
@Override
public boolean matches(Object actualValue) {
HttpMessage message = (HttpMessage) actualValue;
List<HttpHeaderField> headers = message.getRequestHeader().getHeaders();
if (headers.isEmpty()) {
return false;
}
for (HttpHeaderField header : headers) {
if (name.equals(header.getName()) && value.equals(header.getValue())) {
return true;
}
}
return false;
}
@Override
public void describeTo(Description description) {
description.appendText("header ").appendValue(name + ": " + value);
}
public void describeMismatch(Object item, Description description) {
HttpMessage message = (HttpMessage) item;
List<HttpHeaderField> headers = message.getRequestHeader().getHeaders();
if (headers.isEmpty()) {
description.appendText("has no headers");
} else {
description.appendText("was ").appendValue(headers);
}
}
};
}
Aggregations