本文整理匯總了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;
}
示例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;
}
示例3: Builder
import org.eclipse.jetty.client.HttpClient; //導入方法依賴的package包/類
public Builder(HttpClient client, String uri) {
this(client.newRequest(uri));
}