本文整理汇总了Java中com.epam.reportportal.apache.http.HttpRequestInterceptor.process方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestInterceptor.process方法的具体用法?Java HttpRequestInterceptor.process怎么用?Java HttpRequestInterceptor.process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.epam.reportportal.apache.http.HttpRequestInterceptor
的用法示例。
在下文中一共展示了HttpRequestInterceptor.process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAuthDefaultHttpPortWhenProxy
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testAuthDefaultHttpPortWhenProxy() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/stuff");
this.target = new HttpHost("localhost.local");
final HttpRoute route = new HttpRoute(
new HttpHost("localhost.local", 80), null, new HttpHost("localhost", 8888), false);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final CookieOrigin cookieOrigin = context.getCookieOrigin();
Assert.assertNotNull(cookieOrigin);
Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
Assert.assertEquals(80, cookieOrigin.getPort());
Assert.assertEquals("/stuff", cookieOrigin.getPath());
Assert.assertFalse(cookieOrigin.isSecure());
}
示例2: testAuthCacheNotSet
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testAuthCacheNotSet() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credProvider);
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);
context.setAttribute(HttpClientContext.AUTH_CACHE, null);
final HttpRequestInterceptor interceptor = new RequestAuthCache();
interceptor.process(request, context);
Assert.assertNull(this.targetState.getAuthScheme());
Assert.assertNull(this.targetState.getCredentials());
Assert.assertNull(this.proxyState.getAuthScheme());
Assert.assertNull(this.proxyState.getCredentials());
}
示例3: testConnectionKeepAliveForTunneledRequests
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testConnectionKeepAliveForTunneledRequests() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpClientContext context = HttpClientContext.create();
final HttpHost target = new HttpHost("localhost", 443, "https");
final HttpHost proxy = new HttpHost("localhost", 8080);
final HttpRoute route = new HttpRoute(target, null, proxy, true,
TunnelType.TUNNELLED, LayerType.LAYERED);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
Assert.assertNotNull(header1);
Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
final Header header2 = request.getFirstHeader("Proxy-Connection");
Assert.assertNull(header2);
}
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:22,代码来源:TestRequestClientConnControl.java
示例4: testAuthDefaultHttpsPortWhenProxy
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testAuthDefaultHttpsPortWhenProxy() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/stuff");
this.target = new HttpHost("localhost", -1, "https");
final HttpRoute route = new HttpRoute(
new HttpHost("localhost", 443, "https"), null,
new HttpHost("localhost", 8888), true, TunnelType.TUNNELLED, LayerType.LAYERED);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final CookieOrigin cookieOrigin = context.getCookieOrigin();
Assert.assertNotNull(cookieOrigin);
Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
Assert.assertEquals(443, cookieOrigin.getPort());
Assert.assertEquals("/stuff", cookieOrigin.getPath());
Assert.assertTrue(cookieOrigin.isSecure());
}
示例5: testNoCookieStore
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testNoCookieStore() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpRoute route = new HttpRoute(this.target, null, false);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, null);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(0, headers1.length);
final Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
}
示例6: testPreserveCustomProxyConnectionHeader
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testPreserveCustomProxyConnectionHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
request.addHeader("Proxy-Connection", HTTP.CONN_CLOSE);
final HttpClientContext context = HttpClientContext.create();
final HttpHost target = new HttpHost("localhost", 80, "http");
final HttpHost proxy = new HttpHost("localhost", 8080);
final HttpRoute route = new HttpRoute(target, null, proxy, false,
TunnelType.PLAIN, LayerType.PLAIN);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
final Header header1 = request.getFirstHeader("Proxy-Connection");
Assert.assertNotNull(header1);
Assert.assertEquals(HTTP.CONN_CLOSE, header1.getValue());
}
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:21,代码来源:TestRequestClientConnControl.java
示例7: testNoTargetHost
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testNoTargetHost() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpRoute route = new HttpRoute(this.target, null, false);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, null);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(0, headers1.length);
final Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
}
示例8: testNoHttpConnection
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testNoHttpConnection() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_CONNECTION, null);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(0, headers1.length);
final Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
}
示例9: testConnectionKeepAliveForDirectRequests
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testConnectionKeepAliveForDirectRequests() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpClientContext context = HttpClientContext.create();
final HttpHost target = new HttpHost("localhost", 80, "http");
final HttpRoute route = new HttpRoute(target, null, false);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
Assert.assertNotNull(header1);
Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
final Header header2 = request.getFirstHeader("Proxy-Connection");
Assert.assertNull(header2);
}
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:20,代码来源:TestRequestClientConnControl.java
示例10: process
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
public void process(
final HttpRequest request,
final HttpContext context) throws IOException, HttpException {
for (final HttpRequestInterceptor requestInterceptor : this.requestInterceptors) {
requestInterceptor.process(request, context);
}
}
示例11: testNoMatchingCookies
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testNoMatchingCookies() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
this.cookieStore.clear();
final BasicClientCookie cookie3 = new BasicClientCookie("name3", "value3");
cookie3.setDomain("www.somedomain.com");
cookie3.setPath("/");
this.cookieStore.addCookie(cookie3);
final HttpRoute route = new HttpRoute(this.target, null, false);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(0, headers1.length);
final Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
}
示例12: testAddSpecVersionHeader
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testAddSpecVersionHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
this.cookieStore.clear();
final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value1");
cookie1.setVersion(0);
cookie1.setDomain("localhost.local");
cookie1.setPath("/");
this.cookieStore.addCookie(cookie1);
final BasicClientCookie cookie2 = new BasicClientCookie("name2", "value2");
cookie2.setVersion(0);
cookie2.setDomain("localhost.local");
cookie2.setPath("/");
this.cookieStore.addCookie(cookie2);
final HttpRoute route = new HttpRoute(this.target, null, false);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(1, headers1.length);
Assert.assertEquals("name1=value1; name2=value2", headers1[0].getValue());
final Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(1, headers2.length);
Assert.assertEquals("$Version=1", headers2[0].getValue());
}
示例13: testConnectionKeepAliveForConnectRequest
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testConnectionKeepAliveForConnectRequest() throws Exception {
final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");
final HttpClientContext context = HttpClientContext.create();
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
final Header header1 = request.getFirstHeader("Proxy-Connection");
Assert.assertNotNull(header1);
Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
final Header header2 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
Assert.assertNull(header2);
}
开发者ID:reportportal,项目名称:client-java-httpclient-repacked,代码行数:14,代码来源:TestRequestClientConnControl.java
示例14: testAuthSchemeAlreadySet
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testAuthSchemeAlreadySet() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credProvider);
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);
final AuthCache authCache = new BasicAuthCache();
authCache.put(this.target, this.authscheme1);
authCache.put(this.proxy, this.authscheme2);
context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);
this.targetState.setState(AuthProtocolState.CHALLENGED);
this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3", "secret3"));
this.proxyState.setState(AuthProtocolState.CHALLENGED);
this.proxyState.update(new BasicScheme(), new UsernamePasswordCredentials("user4", "secret4"));
final HttpRequestInterceptor interceptor = new RequestAuthCache();
interceptor.process(request, context);
Assert.assertNotSame(this.authscheme1, this.targetState.getAuthScheme());
Assert.assertNotSame(this.creds1, this.targetState.getCredentials());
Assert.assertNotSame(this.authscheme2, this.proxyState.getAuthScheme());
Assert.assertNotSame(this.creds2, this.proxyState.getCredentials());
}
示例15: testAddCookies
import com.epam.reportportal.apache.http.HttpRequestInterceptor; //导入方法依赖的package包/类
@Test
public void testAddCookies() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpRoute route = new HttpRoute(this.target, null, false);
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
final Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(2, headers1.length);
Assert.assertEquals("$Version=1; name1=\"value1\"", headers1[0].getValue());
Assert.assertEquals("$Version=1; name2=\"value2\"", headers1[1].getValue());
final Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
final CookieOrigin cookieOrigin = context.getCookieOrigin();
Assert.assertNotNull(cookieOrigin);
Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
Assert.assertEquals(this.target.getPort(), cookieOrigin.getPort());
Assert.assertEquals("/", cookieOrigin.getPath());
Assert.assertFalse(cookieOrigin.isSecure());
}