use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project undertow by undertow-io.
the class SimpleConfidentialRedirectTestCase method simpleRedirectTestCase.
@Test
public void simpleRedirectTestCase() throws IOException, GeneralSecurityException {
TestHttpClient client = new TestHttpClient();
// create our own context to force http-request.config
// notice that, if we just create http context, the config is ovewritten before request is sent
// if we add the config to the HttpClient instead, it is ignored
HttpContext httpContext = new BasicHttpContext() {
private final RequestConfig config = RequestConfig.copy(RequestConfig.DEFAULT).setNormalizeUri(false).build();
@Override
public void setAttribute(final String id, final Object obj) {
if ("http.request-config".equals(id))
return;
super.setAttribute(id, obj);
}
@Override
public Object getAttribute(final String id) {
if ("http.request-config".equals(id))
return config;
return super.getAttribute(id);
}
};
client.setSSLContext(DefaultServer.getClientSSLContext());
try {
sendRequest(client, httpContext, "/foo", null);
sendRequest(client, httpContext, "/foo+bar", null);
sendRequest(client, httpContext, "/foo+bar;aa", null);
sendRequest(client, httpContext, "/foo+bar;aa", "x=y");
sendRequest(client, httpContext, "/foo+bar%3Aaa", "x=%3Ablah");
} finally {
client.getConnectionManager().shutdown();
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project stanbol by apache.
the class RequestExecutor method execute.
/**
* Executes a {@link Request} using this executor. <p>
* Note that this cleans up all data of the previous executed request.
* @param r the request to execute
* @return this
* @throws ClientProtocolException
* @throws IOException
*/
public RequestExecutor execute(Request r) throws ClientProtocolException, IOException {
clear();
request = r.getRequest();
RequestConfig rc = RequestConfig.custom().setRedirectsEnabled(r.getRedirects()).setRelativeRedirectsAllowed(true).build();
request.setConfig(rc);
// Execute request
response = httpClient.execute(request);
entity = response.getEntity();
if (entity != null) {
// We fully read the content every time, not super efficient but
// how can we read it on demand while avoiding a (boring) cleanup()
// method on this class?
content = EntityUtils.toByteArray(entity);
contentType = ContentType.getOrDefault(entity);
charset = contentType.getCharset();
contentString = new String(content, charset != null ? charset : HTTP.DEF_CONTENT_CHARSET);
// and close the stream
entity.getContent().close();
}
return this;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project stanbol by apache.
the class MultiThreadedTestBase method initialiseHttpClient.
@Before
public void initialiseHttpClient() {
if (this.pooledHttpClient == null) {
// init for the first test
RequestConfig requestConfig = RequestConfig.custom().setRedirectsEnabled(true).setMaxRedirects(3).build();
SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true).build();
connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setDefaultSocketConfig(socketConfig);
connectionManager.setMaxTotal(20);
connectionManager.setDefaultMaxPerRoute(20);
pooledHttpClient = HttpClientBuilder.create().setUserAgent("Stanbol Integration Test").setConnectionManager(connectionManager).setDefaultRequestConfig(requestConfig).build();
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project zm-mailbox by Zimbra.
the class ZimbraAuthToken method encode.
@Override
public void encode(HttpClientBuilder clientBuilder, HttpRequestBase method, boolean isAdminReq, String cookieDomain) throws ServiceException {
String origAuthData = AuthTokenUtil.getOrigAuthData(this);
BasicCookieStore state = new BasicCookieStore();
BasicClientCookie cookie = new BasicClientCookie(ZimbraCookie.authTokenCookieName(isAdminReq), origAuthData);
cookie.setDomain(cookieDomain);
cookie.setPath("/");
cookie.setSecure(false);
state.addCookie(cookie);
clientBuilder.setDefaultCookieStore(state);
RequestConfig reqConfig = RequestConfig.copy(ZimbraHttpConnectionManager.getInternalHttpConnMgr().getZimbraConnMgrParams().getReqConfig()).setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY).build();
clientBuilder.setDefaultRequestConfig(reqConfig);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig in project zm-mailbox by Zimbra.
the class ZimbraAuthToken method encode.
@Override
public void encode(HttpClient client, HttpRequestBase method, boolean isAdminReq, String cookieDomain) throws ServiceException {
String origAuthData = AuthTokenUtil.getOrigAuthData(this);
BasicCookieStore state = new BasicCookieStore();
BasicClientCookie cookie = new BasicClientCookie(ZimbraCookie.authTokenCookieName(isAdminReq), origAuthData);
cookie.setDomain(cookieDomain);
cookie.setPath("/");
cookie.setSecure(false);
state.addCookie(cookie);
HttpClientBuilder clientBuilder = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
clientBuilder.setDefaultCookieStore(state);
RequestConfig reqConfig = RequestConfig.copy(ZimbraHttpConnectionManager.getInternalHttpConnMgr().getZimbraConnMgrParams().getReqConfig()).setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY).build();
clientBuilder.setDefaultRequestConfig(reqConfig);
}
Aggregations