本文整理匯總了Java中org.springframework.http.client.ClientHttpRequest.getHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientHttpRequest.getHeaders方法的具體用法?Java ClientHttpRequest.getHeaders怎麽用?Java ClientHttpRequest.getHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.http.client.ClientHttpRequest
的用法示例。
在下文中一共展示了ClientHttpRequest.getHeaders方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onApplicationEvent
import org.springframework.http.client.ClientHttpRequest; //導入方法依賴的package包/類
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {
try {
ClassLoaderFiles classLoaderFiles = getClassLoaderFiles(event);
ClientHttpRequest request = this.requestFactory.createRequest(this.uri,
HttpMethod.POST);
byte[] bytes = serialize(classLoaderFiles);
HttpHeaders headers = request.getHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentLength(bytes.length);
FileCopyUtils.copy(bytes, request.getBody());
logUpload(classLoaderFiles);
ClientHttpResponse response = request.execute();
Assert.state(response.getStatusCode() == HttpStatus.OK, "Unexpected "
+ response.getStatusCode() + " response uploading class files");
}
catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
示例2: createRequest
import org.springframework.http.client.ClientHttpRequest; //導入方法依賴的package包/類
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod);
HttpHeaders requestHeaders = request.getHeaders();
if (!requestHeaders.containsKey(HttpHeaders.AUTHORIZATION)) {
requestHeaders.add(HttpHeaders.AUTHORIZATION, "Bearer " + computeAuthorizationToken());
}
return request;
}
示例3: getOrCreateWorkflowAndAddInteraction
import org.springframework.http.client.ClientHttpRequest; //導入方法依賴的package包/類
private void getOrCreateWorkflowAndAddInteraction(Pact pact, ClientHttpRequest clientRequest, ClientHttpResponse response) throws IOException {
String bodyString = StreamUtils.copyToString(response.getBody(), Charset.defaultCharset());
response.getBody().reset();
Pact.Interaction interaction = new Pact.Interaction(
null,
new Pact.InteractionRequest(restRequestDescriptor.getMethod(), urlencode(restRequestDescriptor.getUrl()), clientRequest.getHeaders(), extractBodyContent(restRequestDescriptor.getRequest())),
new Pact.InteractionResponse(response.getRawStatusCode(), response.getHeaders(), bodyString, schema),
objectConverter);
Pact.Workflow workflow = pact.getWorkflow(this.workflowId, this.providerStates);
workflow.addInteraction(interaction);
}
示例4: createRequest
import org.springframework.http.client.ClientHttpRequest; //導入方法依賴的package包/類
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
ClientHttpRequest request = super.createRequest(uri, httpMethod);
HttpHeaders headers = request.getHeaders();
headers.add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0");
headers.add("Connection", "keep-alive");
return request;
}