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


Java HttpClient.newRequest方法代碼示例

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


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

示例1: newRequest

import org.eclipse.jetty.client.HttpClient; //導入方法依賴的package包/類
public Request newRequest(HttpClient httpClient) {
    Request request = httpClient.newRequest(uri);
    request.content(contentProvider).method(method);

    for (String key : headers.keySet()) {
        if (! "User-Agent".equals(key)) {
            request.header(key, headers.get(key));
        }
    }

    return request;
}
 
開發者ID:Sixt,項目名稱:ja-micro,代碼行數:13,代碼來源:HttpRequestWrapper.java

示例2: submit

import org.eclipse.jetty.client.HttpClient; //導入方法依賴的package包/類
@Override
public ResponseEntity<String> submit(JCurlRequestOptions requestOptions) throws Exception {

    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setSslContext(SSLContext.getDefault());
    HttpClient httpClient = new HttpClient(sslContextFactory);
    // Configure HttpClient here
    httpClient.start();

    ResponseEntity<String> responseEntity = null;

    for (int i=0;i< requestOptions.getCount();i++) {
        final Request request = httpClient
            .newRequest(requestOptions.getUrl());

        for(Map.Entry<String,String> e : requestOptions.getHeaderMap().entrySet()) {
            request.header(e.getKey(), e.getValue());
        }

        System.out.println("\nSending 'GET' request to URL : " + requestOptions.getUrl());
        final ContentResponse response = request.send();

        int responseCode = response.getStatus();
        System.out.println("Response Code : " + responseCode);

        String responseContent = IOUtils.toString(response.getContent(), "utf-8");

        //print result
        System.out.println(responseContent);

        responseEntity = new ResponseEntity<String>(responseContent, HttpStatus.valueOf(responseCode));
    }

    httpClient.stop();
    return responseEntity;
}
 
開發者ID:eeichinger,項目名稱:jcurl,代碼行數:37,代碼來源:JettyEngine.java

示例3: Builder

import org.eclipse.jetty.client.HttpClient; //導入方法依賴的package包/類
public Builder(HttpClient client, String uri) {
    this(client.newRequest(uri));
}
 
開發者ID:jetty-project,項目名稱:jetty-reactive-httpclient,代碼行數:4,代碼來源:ReactiveRequest.java


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