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


Java Request.method方法代码示例

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


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

示例1: setHeaderAndQueryInfo

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
private static Request setHeaderAndQueryInfo(Request request, ResponseInfo responseInfo) {
    Map<String, String> requestHeaders = responseInfo.getHeaders();

    for ( String headerKey : requestHeaders.keySet() ) {
        request.header(headerKey, requestHeaders.get(headerKey));
    }

    request.method(request.getMethod());
    request.accept(responseInfo.getRequestAccept());

    Map<String, String> requestQueryParams = responseInfo.getQueryStringMap();
    for ( String queryKey : requestQueryParams.keySet() ) {
        request.param(queryKey, requestQueryParams.get(queryKey));
    }

    return request;
}
 
开发者ID:longcoding,项目名称:undefined-gateway,代码行数:18,代码来源:ProxyServiceImpl.java

示例2: restPostRequest

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
private String restPostRequest(String endpoint, String content) {
  try {
    LOGGER.debug("Sending POST request to: " + config.getRsServerUrl() + endpoint);
    httpClient.start();
    Request request = httpClient.newRequest(config.getRsServerUrl() + endpoint);
    request = request.method(HttpMethod.POST);
    request = request.content(new StringContentProvider(content, "UTF-8"));
    ContentResponse response = request.send();
    httpClient.stop();
    LOGGER.debug("Got response: " + response.getContentAsString());
    return response.getContentAsString();
  } catch (Exception e) {
    LOGGER.error(null, e);
    return "";
  }
}
 
开发者ID:Braveno,项目名称:cosigner,代码行数:17,代码来源:AdminConnector.java

示例3: bloomFilterPersist

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@SqlType(StandardTypes.BOOLEAN)
@Nullable
@SqlNullable
public static Boolean bloomFilterPersist(@SqlNullable @SqlType(BloomFilterType.TYPE) Slice bloomFilterSlice, @SqlType(StandardTypes.VARCHAR) Slice urlSlice) throws Exception
{
    // Nothing todo
    if (urlSlice == null) {
        return true;
    }
    BloomFilter bf = getOrLoadBloomFilter(bloomFilterSlice);

    // Persist
    // we do not try catch here to make sure that errors are communicated clearly to the client
    // and typical retry logic continues to work
    String url = new String(urlSlice.getBytes());
    if (!HTTP_CLIENT.isStarted()) {
        log.warn("Http client was not started, trying to start");
        HTTP_CLIENT.start();
    }
    Request post = HTTP_CLIENT.POST(url);
    post.content(new StringContentProvider(new String(bf.toBase64())));
    post.method("PUT");
    post.send();
    log.info("Persisted " + bf.toString() + " " + url);
    return true;
}
 
开发者ID:RobinUS2,项目名称:presto-bloomfilter,代码行数:27,代码来源:BloomFilterPersistScalarFunction.java

示例4: fromUrl

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
public static BloomFilter fromUrl(String url) throws Exception
{
    log.info("Loading bloom filter from " + url);

    Request request = BloomFilterScalarFunctions.HTTP_CLIENT.newRequest(url);
    request.method("GET");
    InputStreamResponseListener listener = new InputStreamResponseListener();
    request.send(listener);

    // Wait for the response headers to arrive
    Response response = listener.get(10, TimeUnit.SECONDS);

    // Look at the response
    if (response.getStatus() == 200) {
        // Use try-with-resources to close input stream.
        try (InputStream responseContent = listener.getInputStream()) {
            byte[] bytes = ByteStreams.toByteArray(responseContent);
            return newInstance(bytes);
        }
    }
    log.warn("Non-200 response status " + response.getStatus());
    return null;
}
 
开发者ID:RobinUS2,项目名称:presto-bloomfilter,代码行数:24,代码来源:BloomFilter.java

示例5: testSubscriptionDoesntExist

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testSubscriptionDoesntExist() throws Exception {
    String subscription = producer.generateSubscriptionKey();
    String requestUrl = producer.generateHashedURLFromKey("subscription", subscription);

    HttpClient client = new HttpClient();
    client.setFollowRedirects(false);
    client.start();

    Request request = client.newRequest(requestUrl);
    request.method(HttpMethod.POST);
    request.content(new InputStreamContentProvider(getClass().getResourceAsStream("/server_test_unsubscribe.xml")));

    ContentResponse response = request.send();
    assertEquals("Response was wrong for url http://" + requestUrl, 500, response.getStatus());
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:17,代码来源:SimpleSubscriptionManagerTest.java

示例6: testRenew

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testRenew() throws Exception {

    String subscription = producer.generateSubscriptionKey();
    String requestUrl = producer.generateHashedURLFromKey("subscription", subscription);

    manager.addSubscriber(subscription, System.currentTimeMillis());

    HttpClient client = new HttpClient();
    client.setFollowRedirects(false);
    client.start();

    Request request = client.newRequest(requestUrl);
    request.method(HttpMethod.POST);
    request.content(new InputStreamContentProvider(getClass().getResourceAsStream("/server_test_renew.xml")));

    ContentResponse response = request.send();
    assertEquals("Response status was wrong", 200, response.getStatus());
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:20,代码来源:SimpleSubscriptionManagerTest.java

示例7: testSimpleServer

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testSimpleServer() throws Exception {

    // Start the client
    SslContextFactory sslFactory = new SslContextFactory();

    HttpClient client = new HttpClient(sslFactory);
    client.setFollowRedirects(true);
    client.start();

    // Send response
    Request request = client.newRequest("http://localhost:8080/");
    request.method(HttpMethod.POST);
    request.header(HttpHeader.CONTENT_TYPE, "application");
    request.header(HttpHeader.CONTENT_LENGTH, "200");
    request.content(new InputStreamContentProvider(getClass().getResourceAsStream("/server_test_html_content.html")),
                                                                       "text/html;charset/utf-8");
    ContentResponse response = request.send();
    assertEquals("Response on bad request was not 500", 500, response.getStatus());
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:21,代码来源:ApplicationServerTest.java

示例8: testSendingXML

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testSendingXML() throws Exception {

    // Start the client
    SslContextFactory sslFactory = new SslContextFactory();

    HttpClient client = new HttpClient(sslFactory);
    client.setFollowRedirects(true);
    client.start();

    // Send response
    Request request = client.newRequest("http://localhost:8080/");
    request.method(HttpMethod.POST);
    request.header(HttpHeader.CONTENT_TYPE, "application");
    request.header(HttpHeader.CONTENT_LENGTH, "200");
    request.content(new InputStreamContentProvider(getClass().getResourceAsStream("/server_test_xml.xml")),
            "application/soap+xml;charset/utf-8");

    ContentResponse response = request.send();
    assertEquals("Response on bad request was not 500", 500, response.getStatus());
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:22,代码来源:ApplicationServerTest.java

示例9: testSendingSoap

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testSendingSoap() throws Exception {
    SoapForwardingHub soapForwardingHub = new SoapForwardingHub();

    // Start the client
    SslContextFactory sslFactory = new SslContextFactory();

    HttpClient client = new HttpClient(sslFactory);
    client.setFollowRedirects(true);
    client.start();

    Object object = XMLParser.parse(getClass().getResourceAsStream("/server_test_soap.xml"));
    Envelope env = (Envelope)((JAXBElement)((InternalMessage) object).getMessage()).getValue();
    Header head = env.getHeader();
    Body body = env.getBody();

    // Send response
    Request request = client.newRequest("http://localhost:8080/");
    request.method(HttpMethod.POST);
    request.content(new InputStreamContentProvider(getClass().getResourceAsStream("/server_test_soap.xml")),
            "application/soap+xml;charset/utf-8");

    ContentResponse response = request.send();
    assertEquals("Expected not found", 404, response.getStatus());
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:26,代码来源:ApplicationServerTest.java

示例10: testSubscribe

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testSubscribe() throws Exception {

    // Start the client
    SslContextFactory sslFactory = new SslContextFactory();

    HttpClient client = new HttpClient(sslFactory);
    client.setFollowRedirects(true);
    client.start();

    // Send response
    InputStream file = getClass().getResourceAsStream("/server_test_subscribe.xml");

    Request request = client.newRequest("http://localhost:8080/");
    request.method(HttpMethod.POST);
    request.header(HttpHeader.CONTENT_TYPE, "application");
    request.header(HttpHeader.CONTENT_LENGTH, "200");
    request.content(new InputStreamContentProvider(file),
            "application/soap+xml;charset/utf-8");

    ContentResponse response = request.send();
    assertEquals("Expected not found", 404, response.getStatus());
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:24,代码来源:ApplicationServerTest.java

示例11: post

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Override
public <T> Response<T> post(String uri, HttpFields headers, String body, MediaType bodyMediaType, Class<T> expectedModel) throws Exception {
  Request request = newRequest(uri);
  request.method(HttpMethod.POST);
  request.content(new StringContentProvider(body, mediaTypeToCharset(bodyMediaType)));

  headers = appendDefaultPostHeaders(headers, body, bodyMediaType);
  return execute(request, headers, expectedModel);
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:10,代码来源:WebClientImpl.java

示例12: put

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Override
public <T> Response<T> put(String uri, HttpFields headers, String body, MediaType bodyMediaType, Class<T> expectedModel) throws Exception {
  Request request = newRequest(uri);
  request.method(HttpMethod.PUT);
  request.content(new StringContentProvider(body, mediaTypeToCharset(bodyMediaType)));

  headers = appendDefaultPostHeaders(headers, body, bodyMediaType);
  return execute(request, headers, expectedModel);
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:10,代码来源:WebClientImpl.java

示例13: retryRequest

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
private void retryRequest(SalesforceHttpRequest request, AbstractClientBase client, Integer retries, HttpConversation conversation,
                          boolean copy) {
    // copy the request to resend
    // TODO handle a change in Salesforce instanceUrl, right now we retry with the same destination
    final Request newRequest;
    if (copy) {
        newRequest = httpClient.copyRequest(request, request.getURI());
        newRequest.method(request.getMethod());
    } else {
        newRequest = request;
    }

    conversation.setAttribute(AUTHENTICATION_RETRIES_ATTRIBUTE, ++retries);

    LOG.debug("Retry attempt {} on authentication error for {}", retries, request);

    // update currentToken
    String currentToken = session.getAccessToken();
    if (client != null) {
        // update client cache for this and future requests
        client.setAccessToken(currentToken);
        client.setInstanceUrl(session.getInstanceUrl());
        client.setAccessToken(newRequest);
    } else {
        // plain request not made by an AbstractClientBase
        newRequest.header(HttpHeader.AUTHORIZATION, "OAuth " + currentToken);
    }

    // send new async request with a new delegate
    conversation.updateResponseListeners(null);
    newRequest.onRequestBegin(getRequestAbortListener(request));
    newRequest.send(null);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:SalesforceSecurityHandler.java

示例14: restGetRequest

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
private String restGetRequest(String endpoint) {
  try {
    LOGGER.debug("Sending GET request to: " + config.getRsServerUrl() + endpoint);
    httpClient.start();
    Request request = httpClient.newRequest(config.getRsServerUrl() + endpoint);
    request = request.method(HttpMethod.GET);
    ContentResponse response = request.send();
    httpClient.stop();
    LOGGER.debug("Got response: " + response.getContentAsString());
    return response.getContentAsString();
  } catch (Exception e) {
    LOGGER.error(null, e);
    return "";
  }
}
 
开发者ID:Braveno,项目名称:cosigner,代码行数:16,代码来源:AdminConnector.java

示例15: testUnsubscribe

import org.eclipse.jetty.client.api.Request; //导入方法依赖的package包/类
@Test
public void testUnsubscribe() throws Exception {

    String subscription = producer.generateSubscriptionKey();
    String requestUrl = producer.generateHashedURLFromKey("subscription", subscription);

    manager.addSubscriber(subscription, System.currentTimeMillis());

    InputStream stream = getClass().getResourceAsStream("/server_test_unsubscribe.xml");

    HttpClient client = new HttpClient();
    client.setFollowRedirects(false);
    client.start();

    // Test without requestURL
    Request request = client.newRequest("http://localhost:8080/"+"?subscription="+subscription);
    request.method(HttpMethod.POST);
    request.content(new InputStreamContentProvider(stream));

    ContentResponse response = request.send();
    String responseContent = response.getContentAsString();
    assertEquals("Test without request URL", 200, response.getStatus());
    assertNotNull(responseContent);

    manager.addSubscriber(subscription, System.currentTimeMillis());

    // Test with requestURL
    request = client.newRequest(requestUrl);
    request.method(HttpMethod.POST);
    request.content(new InputStreamContentProvider(getClass().getResourceAsStream("/server_test_unsubscribe.xml")));

    response = request.send();
    responseContent = response.getContentAsString();
    assertEquals("Test with request URL", 200, response.getStatus());
    assertNotNull("ResponseContent was null: No content was returned", responseContent);
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:37,代码来源:SimpleSubscriptionManagerTest.java


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