Java Code Examples for org.apache.http.client.methods.HttpEntityEnclosingRequestBase#setHeader()
The following examples show how to use
org.apache.http.client.methods.HttpEntityEnclosingRequestBase#setHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: P2ResourceITSupport.java From nexus-repository-p2 with Eclipse Public License 1.0 | 5 votes |
private void prepareRequest(HttpEntityEnclosingRequestBase request, String url, Object body) throws Exception { request.setEntity(new ByteArrayEntity(OBJECT_MAPPER.writeValueAsBytes(body), ContentType.APPLICATION_JSON)); UriBuilder uriBuilder = UriBuilder.fromUri(nexusUrl.toString()).path(url); request.setURI(uriBuilder.build()); String auth = credentials.getUserName() + ":" + credentials.getPassword(); request.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8)))); }
Example 2
Source File: ResourceITSupport.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
private void prepareRequest(HttpEntityEnclosingRequestBase request, String url, Object body) throws Exception { request.setEntity(new ByteArrayEntity(objectMapper.writeValueAsBytes(body), ContentType.APPLICATION_JSON)); UriBuilder uriBuilder = UriBuilder.fromUri(nexusUrl.toString()).path(url); request.setURI(uriBuilder.build()); String auth = credentials.getUserName() + ":" + credentials.getPassword(); request.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8)))); }
Example 3
Source File: RResourceITSupport.java From nexus-repository-r with Eclipse Public License 1.0 | 5 votes |
private void prepareRequest(HttpEntityEnclosingRequestBase request, String url, Object body) throws Exception { request.setEntity(new ByteArrayEntity(objectMapper.writeValueAsBytes(body), ContentType.APPLICATION_JSON)); UriBuilder uriBuilder = UriBuilder.fromUri(nexusUrl.toString()).path(url); request.setURI(uriBuilder.build()); String auth = credentials.getUserName() + ":" + credentials.getPassword(); request.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8)))); }
Example 4
Source File: ConanResourceITSupport.java From nexus-repository-conan with Eclipse Public License 1.0 | 5 votes |
private void prepareRequest(HttpEntityEnclosingRequestBase request, String url, Object body) throws Exception { request.setEntity(new ByteArrayEntity(objectMapper.writeValueAsBytes(body), ContentType.APPLICATION_JSON)); UriBuilder uriBuilder = UriBuilder.fromUri(nexusUrl.toString()).path(url); request.setURI(uriBuilder.build()); String auth = credentials.getUserName() + ":" + credentials.getPassword(); request.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8)))); }
Example 5
Source File: HttpUtil.java From pnc with Apache License 2.0 | 5 votes |
private static InputStream doPostOrPut( String contentType, String acceptType, String content, String authorization, HttpEntityEnclosingRequestBase request) throws IOException { request.setHeader(HttpHeaders.CONTENT_TYPE, contentType); request.setHeader(HttpHeaders.ACCEPT, acceptType); if (content != null) { request.setEntity(new StringEntity(content)); } return doRequest(authorization, request); }
Example 6
Source File: HttpUtil.java From keycloak with Apache License 2.0 | 5 votes |
private static InputStream doPostOrPut(String contentType, String acceptType, String content, String authorization, HttpEntityEnclosingRequestBase request) throws IOException { request.setHeader(HttpHeaders.CONTENT_TYPE, contentType); request.setHeader(HttpHeaders.ACCEPT, acceptType); if (content != null) { request.setEntity(new StringEntity(content)); } return doRequest(authorization, request); }
Example 7
Source File: HttpUtil.java From keycloak with Apache License 2.0 | 5 votes |
private static InputStream doPostOrPut(String contentType, String acceptType, String content, String authorization, HttpEntityEnclosingRequestBase request) throws IOException { request.setHeader(HttpHeaders.CONTENT_TYPE, contentType); request.setHeader(HttpHeaders.ACCEPT, acceptType); if (content != null) { request.setEntity(new StringEntity(content)); } return doRequest(authorization, request); }