use of org.apache.commons.httpclient.cookie.CookieSpec in project tdi-studio-se by Talend.
the class HttpMethodBase method processResponseHeaders.
/**
* This method is invoked immediately after
* {@link #readResponseHeaders(HttpState,HttpConnection)} and can be overridden by
* sub-classes in order to provide custom response headers processing.
* <p>
* This implementation will handle the <tt>Set-Cookie</tt> and
* <tt>Set-Cookie2</tt> headers, if any, adding the relevant cookies to
* the given {@link HttpState}.
* </p>
*
* @param state the {@link HttpState state} information associated with this method
* @param conn the {@link HttpConnection connection} used to execute
* this HTTP method
*
* @see #readResponse
* @see #readResponseHeaders
*/
protected void processResponseHeaders(HttpState state, HttpConnection conn) {
LOG.trace("enter HttpMethodBase.processResponseHeaders(HttpState, " + "HttpConnection)");
CookieSpec parser = getCookieSpec(state);
// process set-cookie headers
Header[] headers = getResponseHeaderGroup().getHeaders("set-cookie");
processCookieHeaders(parser, headers, state, conn);
// see if the cookie spec supports cookie versioning.
if (parser instanceof CookieVersionSupport) {
CookieVersionSupport versupport = (CookieVersionSupport) parser;
if (versupport.getVersion() > 0) {
// process set-cookie2 headers.
// Cookie2 will replace equivalent Cookie instances
headers = getResponseHeaderGroup().getHeaders("set-cookie2");
processCookieHeaders(parser, headers, state, conn);
}
}
}
use of org.apache.commons.httpclient.cookie.CookieSpec in project zaproxy by zaproxy.
the class ZapCookieSpecUnitTest method shouldThrowWhenValidatingWithNullCookie.
@Test
void shouldThrowWhenValidatingWithNullCookie() throws MalformedCookieException {
// Given
CookieSpec cookieSpec = createCookieSpec();
Cookie cookie = null;
// When / Then
assertThrows(NullPointerException.class, () -> cookieSpec.validate(HOST, PORT, PATH, SECURE, cookie));
}
use of org.apache.commons.httpclient.cookie.CookieSpec in project zaproxy by zaproxy.
the class ZapCookieSpecUnitTest method shouldThrowWhenValidatingWithNullCookieDomain.
@Test
void shouldThrowWhenValidatingWithNullCookieDomain() throws MalformedCookieException {
// Given
CookieSpec cookieSpec = createCookieSpec();
Cookie cookie = new Cookie(null, "name", "value");
// When / Then
assertThrows(NullPointerException.class, () -> cookieSpec.validate(HOST, PORT, PATH, SECURE, cookie));
}
use of org.apache.commons.httpclient.cookie.CookieSpec in project zaproxy by zaproxy.
the class ZapCookieSpecUnitTest method shouldThrowWhenValidatingWithEmptyHost.
@Test
void shouldThrowWhenValidatingWithEmptyHost() throws MalformedCookieException {
// Given
CookieSpec cookieSpec = createCookieSpec();
String host = "";
// When / Then
assertThrows(IllegalArgumentException.class, () -> cookieSpec.validate(host, PORT, PATH, SECURE, new Cookie()));
}
use of org.apache.commons.httpclient.cookie.CookieSpec in project zaproxy by zaproxy.
the class ZapCookieSpecUnitTest method shouldThrowWhenValidatingWithNullPath.
@Test
void shouldThrowWhenValidatingWithNullPath() throws MalformedCookieException {
// Given
CookieSpec cookieSpec = createCookieSpec();
String path = null;
// When / Then
assertThrows(IllegalArgumentException.class, () -> cookieSpec.validate(HOST, PORT, path, SECURE, new Cookie()));
}
Aggregations