当前位置: 首页>>代码示例>>Java>>正文


Java HttpHeaders.setUserAgent方法代码示例

本文整理汇总了Java中com.google.api.client.http.HttpHeaders.setUserAgent方法的典型用法代码示例。如果您正苦于以下问题:Java HttpHeaders.setUserAgent方法的具体用法?Java HttpHeaders.setUserAgent怎么用?Java HttpHeaders.setUserAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.http.HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.setUserAgent方法的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: testUserAgentHeader

import com.google.api.client.http.HttpHeaders; //导入方法依赖的package包/类
@Test
public void testUserAgentHeader() throws DnsimpleException, IOException {
  HttpHeaders headers = getDefaultHeaders();
  headers.setUserAgent("my-user-agent dnsimple-java/0.3.0 Google-HTTP-Java-Client/1.20.0 (gzip)");

  Client client = mockAndExpectClient("https://api.dnsimple.com/v2/accounts", HttpMethods.GET, headers, null, resource("listAccounts/success-account.http"));
  client.setUserAgent("my-user-agent");
  client.accounts.listAccounts();
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:10,代码来源:ClientTest.java

示例3: initializeBigqueryRequest

import com.google.api.client.http.HttpHeaders; //导入方法依赖的package包/类
@Override
public void initializeBigqueryRequest(BigqueryRequest<?> request) throws IOException {
    if (userAgent != null) {
        HttpHeaders currentHeaders = request.getRequestHeaders();

        currentHeaders.setUserAgent(userAgent);

        request.setRequestHeaders(currentHeaders);
    }
}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:11,代码来源:Oauth2Bigquery.java

示例4: 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

示例5: createHeaders

import com.google.api.client.http.HttpHeaders; //导入方法依赖的package包/类
/**
 * Creates the http headers object for this request, populated from data in
 * the session.
 * @throws AuthenticationException If OAuth authorization fails.
 */
private HttpHeaders createHeaders(String reportUrl, String version)
    throws AuthenticationException {
  HttpHeaders httpHeaders = new HttpHeaders();
  httpHeaders.setAuthorization(
      authorizationHeaderProvider.getAuthorizationHeader(session, reportUrl));
  httpHeaders.setUserAgent(userAgentCombiner.getUserAgent(session.getUserAgent()));
  httpHeaders.set("developerToken", session.getDeveloperToken());
  httpHeaders.set("clientCustomerId", session.getClientCustomerId());
  ReportingConfiguration reportingConfiguration = session.getReportingConfiguration();
  if (reportingConfiguration != null) {
    reportingConfiguration.validate(version);
    if (reportingConfiguration.isSkipReportHeader() != null) {
      httpHeaders.set("skipReportHeader",
          Boolean.toString(reportingConfiguration.isSkipReportHeader()));
    }
    if (reportingConfiguration.isSkipColumnHeader() != null) {
      httpHeaders.set("skipColumnHeader",
          Boolean.toString(reportingConfiguration.isSkipColumnHeader()));
    }
    if (reportingConfiguration.isSkipReportSummary() != null) {
      httpHeaders.set("skipReportSummary",
          Boolean.toString(reportingConfiguration.isSkipReportSummary()));
    }
    if (reportingConfiguration.isIncludeZeroImpressions() != null) {
      httpHeaders.set(
          "includeZeroImpressions",
          Boolean.toString(reportingConfiguration.isIncludeZeroImpressions()));
    }
    if (reportingConfiguration.isUseRawEnumValues() != null) {
      httpHeaders.set(
          "useRawEnumValues",
          Boolean.toString(reportingConfiguration.isUseRawEnumValues()));
    }
  }
  return httpHeaders;
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:42,代码来源:ReportRequestFactoryHelper.java

示例6: 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

示例7: createHttpHeaders

import com.google.api.client.http.HttpHeaders; //导入方法依赖的package包/类
private HttpHeaders createHttpHeaders() {
  HttpHeaders headers = new HttpHeaders();
  headers.setContentType("application/xml");
  headers.setUserAgent(session.getUserAgent());
  return headers;
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:7,代码来源:BatchJobUploader.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.setUserAgent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。