use of org.parosproxy.paros.network.HttpRequestHeader in project zaproxy by zaproxy.
the class FilterIfModifiedSince method onHttpRequestSend.
@Override
public void onHttpRequestSend(HttpMessage httpMessage) {
HttpRequestHeader reqHeader = httpMessage.getRequestHeader();
if (!reqHeader.isEmpty() && reqHeader.isText()) {
String ifModifed = reqHeader.getHeader(HttpHeader.IF_MODIFIED_SINCE);
if (ifModifed != null) {
reqHeader.setHeader(HttpHeader.IF_MODIFIED_SINCE, null);
}
String ifNoneMatch = reqHeader.getHeader(HttpHeader.IF_NONE_MATCH);
if (ifNoneMatch != null) {
reqHeader.setHeader(HttpHeader.IF_NONE_MATCH, null);
}
}
}
use of org.parosproxy.paros.network.HttpRequestHeader in project zaproxy by zaproxy.
the class FilterLogCookie method onHttpRequestSend.
@Override
public void onHttpRequestSend(HttpMessage msg) {
HttpRequestHeader header = msg.getRequestHeader();
if (header != null) {
String cookie = header.getHeader("Cookie");
synchronized (cookieList) {
if (cookie != null && cookieList.indexOf(cookie) == -1) {
try {
// ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient
URI uri;
try {
uri = (URI) header.getURI().clone();
} catch (CloneNotSupportedException e) {
throw new URIException(e.getMessage());
}
uri.setQuery(null);
String sUri = uri.toString();
cookieList.add(cookie);
getView().getOutputPanel().append(sUri + DELIM + cookie + "\n");
} catch (URIException e) {
// ZAP: Print stack trace to Output tab
getView().getOutputPanel().append(e);
}
}
}
}
}
use of org.parosproxy.paros.network.HttpRequestHeader in project zaproxy by zaproxy.
the class FilterLogGetQuery method onHttpRequestSend.
@Override
public void onHttpRequestSend(HttpMessage httpMessage) {
HttpRequestHeader reqHeader = httpMessage.getRequestHeader();
if (reqHeader != null && reqHeader.isText() && !reqHeader.isImage()) {
if (reqHeader.getMethod().equalsIgnoreCase(HttpRequestHeader.GET)) {
try {
URI uri = reqHeader.getURI();
// ZAP: Removed unused variable (int pos).
String firstline;
URI newURI = (URI) uri.clone();
String query = newURI.getQuery();
if (query != null) {
newURI.setQuery(null);
firstline = newURI.toString();
// ZAP: Added type arguments.
Hashtable<String, String> param = parseParameter(query);
writeLogFile(firstline, param);
} else {
firstline = uri.toString();
writeLogFile(firstline, null);
}
} catch (Exception aa) {
logger.error(aa.getMessage(), aa);
}
}
}
}
use of org.parosproxy.paros.network.HttpRequestHeader in project zaproxy by zaproxy.
the class FilterZapRequestId method onHttpRequestSend.
@Override
public void onHttpRequestSend(HttpMessage httpMessage) {
HttpRequestHeader rhead = httpMessage.getRequestHeader();
if (rhead.getHeader(HttpHeader.X_ZAP_REQUESTID) == null) {
String sessname = "zap-session";
try {
sessname = URLEncoder.encode(model.getSession().getSessionName(), "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("UTF8 is not supported?! Using fallback session name.", e);
}
rhead.addHeader(HttpHeader.X_ZAP_REQUESTID, sessname + "-" + Long.toString(requestCounter.getAndIncrement()));
}
}
use of org.parosproxy.paros.network.HttpRequestHeader 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()));
}
Aggregations