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


Java HTTPMethod.GET属性代码示例

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


在下文中一共展示了HTTPMethod.GET属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRequestMethod

@Override
public String getRequestMethod() {
	String outMethod = "unknown";
	if (_requestMethod == HTTPMethod.GET) {
		outMethod = "GET";
	} else if (_requestMethod == HTTPMethod.PUT) {
		outMethod = "PUT";
	} else if (_requestMethod == HTTPMethod.POST) {
		outMethod = "POST";
	} else if (_requestMethod == HTTPMethod.HEAD) {
		outMethod = "HEAD";
	} else if (_requestMethod == HTTPMethod.DELETE) {
		outMethod = "DELETE";
	}
	return outMethod;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:16,代码来源:HttpGoogleURLFetchConnectionWrapper.java

示例2: setRequestMethod

@Override
public void setRequestMethod(final String method) throws ProtocolException {
	// Pasar de lo que espera HttpURLConnection de java a lo que espera URLFetch
	if (method.equals("GET")) {
		_requestMethod = HTTPMethod.GET;
	} else if (method.equals("PUT")) {
		_requestMethod = HTTPMethod.PUT;
	} else if (method.equals("POST")) {
		_requestMethod = HTTPMethod.POST;
	} else if (method.equals("HEAD")) {
		_requestMethod = HTTPMethod.HEAD;
	} else if (method.equals("DELETE")) {
		_requestMethod = HTTPMethod.DELETE;
	}
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:15,代码来源:HttpGoogleURLFetchConnectionWrapper.java

示例3: queryDelegateInfo

private ImmutableList<JSONObject> queryDelegateInfo(ServletContext context) throws IOException {
    String eventManagerUrl = context.getInitParameter("eventManagerUrl");
    String[] eventIds = context.getInitParameter("eventIds").split(",");

    FetchOptions fetchOptions =
            FetchOptions.Builder.doNotFollowRedirects().validateCertificate().disallowTruncate();

    ImmutableList.Builder delegateInfo = ImmutableList.<JSONObject>builder();
    for (String eventId : eventIds) {
        String urlStr = String.format("%s/%s/delegates/%s/",
                eventManagerUrl, eventId.trim(), firebaseWrapper.getUserEmail());

        HTTPRequest httpRequest = new HTTPRequest(new URL(urlStr), HTTPMethod.GET, fetchOptions);
        HTTPResponse httpResponse = urlFetchService.fetch(httpRequest);

        switch (httpResponse.getResponseCode()) {
            case 200:
                // Delegate was found.
                delegateInfo.add(new JSONObject(new String(httpResponse.getContent())));
            case 404:
                // Delegate was not found.
                break;
            default:
                // An unexpected error occurred.
                LOG.severe(
                        String.format(
                                "Could not retrieve event delegate info: %s",
                                new String(httpResponse.getContent())));
                break;
        }
    }
    return delegateInfo.build();
}
 
开发者ID:google,项目名称:iosched,代码行数:33,代码来源:RegistrationEndpoint.java

示例4: fetchNonExistentLocalAppThrowsException

@Test(expected = IOException.class)
public void fetchNonExistentLocalAppThrowsException() throws Exception {
    URL selfURL = new URL("BOGUS-" + appUrlBase + "/");
    FetchOptions fetchOptions = FetchOptions.Builder.withDefaults()
        .doNotFollowRedirects()
        .setDeadline(10.0);
    HTTPRequest httpRequest = new HTTPRequest(selfURL, HTTPMethod.GET, fetchOptions);
    URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse httpResponse = urlFetchService.fetch(httpRequest);
    fail("expected exception, got " + httpResponse.getResponseCode());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:11,代码来源:URLFetchServiceTest.java

示例5: testFollowRedirectsExternal

@Test
public void testFollowRedirectsExternal() throws Exception {
    final URL redirectUrl = new URL("http://google.com/");
    final String expectedDestinationURLPrefix = "http://www.google.";

    FetchOptions options = FetchOptions.Builder.followRedirects();

    HTTPRequest request = new HTTPRequest(redirectUrl, HTTPMethod.GET, options);
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    String destinationUrl = response.getFinalUrl().toString();
    assertTrue("Did not get redirected.", destinationUrl.startsWith(expectedDestinationURLPrefix));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:13,代码来源:FetchOptionsBuilderTest.java

示例6: proxy

public void proxy(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  if (!req.getRequestURI().startsWith(sourceUriPrefix)) {
    log.info("Not proxying request to " + req.getRequestURI() + ", does not start with "
        + sourceUriPrefix);
    return;
  }
  String sourceUri = req.getRequestURI();
  String query = req.getQueryString() != null ? "?" + req.getQueryString() : "";
  String targetUri = targetUriPrefix + sourceUri.substring(sourceUriPrefix.length()) + query;
  log.info("Forwarding request: " + sourceUri + query + " to " + targetUri);

  HTTPMethod fetchMethod = HTTPMethod.valueOf(req.getMethod());
  HTTPRequest fetchRequest = new HTTPRequest(new URL(targetUri), fetchMethod);
  // StringBuilder sb = new StringBuilder();
  for (@SuppressWarnings("unchecked")
  Enumeration<String> headers = req.getHeaderNames(); headers.hasMoreElements();) {
    String headerName = headers.nextElement();
    String headerValue = req.getHeader(headerName);
    // sb.append(headerName + ": " + headerValue).append("\n");
    fetchRequest.addHeader(new HTTPHeader(headerName, headerValue));
  }
  // log.info("Headers\n" + sb.toString());
  if (fetchMethod != HTTPMethod.GET) {
    fetchRequest
        .setPayload(copy(req.getInputStream(), new ByteArrayOutputStream()).toByteArray());
    if (req.getRequestURI().startsWith(sourceUriPrefix + "api")) {
      fetchRequest.setHeader(new HTTPHeader("Content-Type", "application/json"));
    }
  }
  HTTPResponse fetchResponse = fetch.fetch(fetchRequest);
  copyResponse(fetchResponse, resp);
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:32,代码来源:ProxyHandler.java

示例7: getResponseGET

public static String getResponseGET(String url, Map<String, String> params, Map<String, String> headers) {
	int retry = 0;
	while (retry < 3) {
		long start = System.currentTimeMillis();
		try {
			URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();
			String urlStr = ToolString.toUrl(url.trim(), params);
			HTTPRequest httpRequest = new HTTPRequest(new URL(urlStr), HTTPMethod.GET, FetchOptions.Builder.withDeadline(deadline));
			if (headers != null) {
				for (String name : headers.keySet()) {
					httpRequest.addHeader(new HTTPHeader(name, headers.get(name)));
				}
			}
			return processResponse(fetcher.fetch(httpRequest));
		} catch (Throwable e) {
			retry++;
			if (e instanceof RuntimeException) {
				throw (RuntimeException) e;
			} else if (retry < 3) {
				logger.warn("retrying after " + (System.currentTimeMillis() - start) + " and " + retry + " retries\n" + e.getClass() + e.getMessage());
			} else {
				logger.error(e.getClass() + "\n" + ToolString.stack2string(e));
			}
		}
	}
	return null;
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:27,代码来源:HttpClientGAE.java


注:本文中的com.google.appengine.api.urlfetch.HTTPMethod.GET属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。