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


Java HttpHeaders.setAccept方法代碼示例

本文整理匯總了Java中com.google.api.client.http.HttpHeaders.setAccept方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders.setAccept方法的具體用法?Java HttpHeaders.setAccept怎麽用?Java HttpHeaders.setAccept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.api.client.http.HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.setAccept方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
public OAuthAccessToken build() throws IOException {
  Url = new GenericUrl(config.getAccessTokenUrl());

  transport = new ApacheHttpTransport();

  HttpRequestFactory requestFactory = transport.createRequestFactory();
  request = requestFactory.buildRequest(HttpMethods.GET, Url, null);

  HttpHeaders headers = new HttpHeaders();
  headers.setUserAgent(config.getUserAgent());
  headers.setAccept(config.getAccept());

  request.setHeaders(headers);
  createRefreshParameters().intercept(request);

  return this;
}
 
開發者ID:XeroAPI,項目名稱:Xero-Java,代碼行數:18,代碼來源:OAuthAccessToken.java

示例2: createHeaders

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
private HttpHeaders createHeaders(String merchantId, String userId, String authKey, String authMethod, String testbedToken) {
    HttpHeaders headers = new HttpHeaders();
    headers.set("X-Mcash-Merchant", merchantId);
    headers.set("X-Mcash-User", userId);
    headers.setAccept("application/vnd.mcash.api.merchant.v1+json");
    if (testbedToken != null) {
        headers.set("X-Testbed-Token", testbedToken);
    }
    if (authMethod.equals("SECRET")) {
        headers.setAuthorization(String.format("SECRET %s", authKey));
    } else {
        throw new IllegalArgumentException("Invalid auth method " + authMethod);
    }
    return headers;
}
 
開發者ID:fiLLLip,項目名稱:java-mapi-client,代碼行數:16,代碼來源:MCashClient.java

示例3: initMfa

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
public static void initMfa(ServerProfile profile) throws IOException {

    	// any simple get request can be used to - we just need to get an access token
    	// whilst the mfatoken is still valid
    	
        // trying to construct the URL like
        // https://api.enterprise.apigee.com/v1/organizations/apigee-cs/apis/taskservice/
        // success response is ignored
    	if (accessToken == null) {
			logger.info("=============Initialising MFA================");
	
	        HttpRequest restRequest = REQUEST_FACTORY
	                .buildGetRequest(new GenericUrl(profile.getHostUrl() + "/"
	                        + profile.getApi_version() + "/organizations/"
	                        + profile.getOrg() + "/apis/"
	                        + profile.getApplication() + "/"));
	        restRequest.setReadTimeout(0);
	        HttpHeaders headers = new HttpHeaders();
	        headers.setAccept("application/json");
	        restRequest.setHeaders(headers);
	
	        try {
	            HttpResponse response = executeAPI(profile, restRequest);            
	            //ignore response - we just wanted the MFA initialised
	            logger.info("=============MFA Initialised================");
	        } catch (HttpResponseException e) {
	            logger.error(e.getMessage());
	            //throw error as there is no point in continuing
	            throw e;
	        }
    	}
    }
 
開發者ID:apigee,項目名稱:apigee-deploy-maven-plugin,代碼行數:33,代碼來源:RestUtil.java

示例4: getRevision

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
public static void getRevision(ServerProfile profile) throws IOException {

        // trying to construct the URL like
        // https://api.enterprise.apigee.com/v1/organizations/apigee-cs/apis/taskservice/
        // response is like
        // {
        // "name" : "taskservice1",
        // "revision" : [ "1" ]
        // }
        HttpRequest restRequest = REQUEST_FACTORY
                .buildGetRequest(new GenericUrl(profile.getHostUrl() + "/"
                        + profile.getApi_version() + "/organizations/"
                        + profile.getOrg() + "/apis/"
                        + profile.getApplication() + "/"));
        restRequest.setReadTimeout(0);
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept("application/json");
        restRequest.setHeaders(headers);

        try {
            HttpResponse response = executeAPI(profile, restRequest);
            AppRevision apprev = response.parseAs(AppRevision.class);
            Collections.sort(apprev.revision, new StringToIntComparator());
            setVersionRevision(apprev.revision.get(0));
            logger.info(PrintUtil.formatResponse(response, gson.toJson(apprev).toString()));
        } catch (HttpResponseException e) {
            logger.error(e.getMessage());
        }
    }
 
開發者ID:apigee,項目名稱:apigee-deploy-maven-plugin,代碼行數:30,代碼來源:RestUtil.java

示例5: getLatestRevision

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
public static String getLatestRevision(ServerProfile profile) throws IOException {

        // trying to construct the URL like
        // https://api.enterprise.apigee.com/v1/organizations/apigee-cs/apis/taskservice/
        // response is like
        // {
        // "name" : "taskservice1",
        // "revision" : [ "1" ]
        // }
    	String revision = "";
        HttpRequest restRequest = REQUEST_FACTORY
                .buildGetRequest(new GenericUrl(profile.getHostUrl() + "/"
                        + profile.getApi_version() + "/organizations/"
                        + profile.getOrg() + "/apis/"
                        + profile.getApplication() + "/"));
        restRequest.setReadTimeout(0);
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept("application/json");
        restRequest.setHeaders(headers);

        try {
            HttpResponse response = executeAPI(profile, restRequest);
            AppRevision apprev = response.parseAs(AppRevision.class);
            Collections.sort(apprev.revision, new StringToIntComparator());
            revision = apprev.revision.get(0);
            logger.info(PrintUtil.formatResponse(response, gson.toJson(apprev).toString()));
        } catch (HttpResponseException e) {
            logger.error(e.getMessage());
        }
        return revision;
    }
 
開發者ID:apigee,項目名稱:apigee-deploy-maven-plugin,代碼行數:32,代碼來源:RestUtil.java

示例6: initialize

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
@Override
public void initialize(JsonHttpRequest request) {
	HttpHeaders headers = request.getRequestHeaders();
	headers.setAccept("gzip");
	headers.setUserAgent(GDCU.APP_NAME + " (gzip)");
	request.setRequestHeaders(headers);
}
 
開發者ID:DarrenMowat,項目名稱:PicSync,代碼行數:8,代碼來源:DriveApi.java

示例7: execute

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
/**
 * Executes the HTTP request for a temporary or long-lived token.
 *
 * @throws IOException 
 */

public final HttpResponse execute() throws IOException  {
	
	ApacheHttpTransport.Builder builder = new ApacheHttpTransport.Builder();
	
	if(this.proxyEnabled) {
		builder.setProxy(this.proxy);
	}
	
	transport = builder.build();

	if(usePost && body != null){
		requestBody = ByteArrayContent.fromString(null, body);
	}
	
	HttpHeaders headers = new HttpHeaders();
	headers.setUserAgent(config.getUserAgent());
	headers.setAccept(accept != null ? accept : config.getAccept());
	
	headers.setContentType(contentType == null ? "application/xml" : contentType);
	
	if(ifModifiedSince != null) {
		//System.out.println("Set Header " + this.ifModifiedSince);
		headers.setIfModifiedSince(this.ifModifiedSince);	
	}

	HttpRequestFactory requestFactory = transport.createRequestFactory();
	HttpRequest request;
	HttpResponse response = null;
	
	request = requestFactory.buildRequest(this.httpMethod, Url, requestBody);
	request.setConnectTimeout(connectTimeout);
	request.setReadTimeout(readTimeout);
	request.setHeaders(headers);
	
	createParameters().intercept(request);
	
	response = request.execute();
	response.setContentLoggingLimit(0);


	return response;
}
 
開發者ID:XeroAPI,項目名稱:Xero-Java,代碼行數:49,代碼來源:OAuthRequestResource.java

示例8: getDefaultHeaders

import com.google.api.client.http.HttpHeaders; //導入方法依賴的package包/類
/**
 * Get the default HttpHeaders that should be expected on every request.
 *
 * You may set additional headers in the collection as necessary.
 *
 * @return The default HttpHeaders
 */
public HttpHeaders getDefaultHeaders() {
  HttpHeaders headers = new HttpHeaders();
  headers.setAccept("application/json");
  headers.setUserAgent("dnsimple-java/0.3.0 Google-HTTP-Java-Client/1.20.0 (gzip)");
  return headers;
}
 
開發者ID:dnsimple,項目名稱:dnsimple-java,代碼行數:14,代碼來源:DnsimpleTestBase.java


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