當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientHttpRequest.getHeaders方法代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:21,代碼來源:ClassPathChangeUploader.java

示例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;
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:10,代碼來源:RestTemplateFactory.java

示例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);
}
 
開發者ID:tyro,項目名稱:pact-spring-mvc,代碼行數:13,代碼來源:ReturnExpect.java

示例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;
}
 
開發者ID:GoldRenard,項目名稱:JuniperBotJ,代碼行數:9,代碼來源:DiscordHttpRequestFactory.java


注:本文中的org.springframework.http.client.ClientHttpRequest.getHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。