本文整理匯總了Java中org.apache.http.client.methods.RequestBuilder.get方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestBuilder.get方法的具體用法?Java RequestBuilder.get怎麽用?Java RequestBuilder.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.client.methods.RequestBuilder
的用法示例。
在下文中一共展示了RequestBuilder.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNextPage
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public <T> Page<T> getNextPage(Page<T> currentPage) throws IOException {
Pagination pagination = currentPage.getPagination();
if (pagination.getNextPage() == null || pagination.getNextPage().isEmpty()) {
return null;
}
RequestBuilder requestBuilder = RequestBuilder.get(pagination.getNextPage());
requestBuilder = addHeaders(requestBuilder);
HttpUriRequest httpUriRequest = requestBuilder.build();
ContentItemsListingResponse response = executeRequest(httpUriRequest, ContentItemsListingResponse.class);
RichTextElementConverter converter = new RichTextElementConverter(
getContentLinkUrlResolver(),
getBrokenLinkUrlResolver(),
getRichTextElementResolver(),
templateEngineConfig,
stronglyTypedContentItemConverter
);
converter.process(response.getItems());
return new Page<>(response, currentPage.getType(), this);
}
示例2: createRequest
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
/**
* Creates a HttpUriRequest based on the metadata configuration.
* @param metadata The metadata configuration.
* @return A configured request object.
*/
private HttpUriRequest createRequest(Map<String, String> metadata) {
String verb = metadata.getOrDefault(VERB_KEY, DEFAULT_VERB);
String url = metadata.get(URL_KEY);
if (url == null || url.isEmpty()) {
throw new IllegalArgumentException("The " + URL_KEY + " must be provided and contain a valid url.");
}
RequestBuilder builder;
if (GET.equals(verb)) {
builder = RequestBuilder.get(url);
} else if (POST.equals(verb)) {
builder = RequestBuilder.post(url);
String body = metadata.getOrDefault(BODY_KEY, EMPTY_BODY);
builder.setEntity(new StringEntity(body, Charset.defaultCharset()));
} else {
throw new UnsupportedOperationException("This HTTP method is not currently supported: " + verb);
}
// Everything else is assumed to be a header
metadata.entrySet().stream().filter(entry -> !KNOWN_KEYS.contains(entry.getKey()))
.forEach(entry -> builder.addHeader(entry.getKey(), entry.getValue()));
return builder.build();
}
示例3: selectRequestMethod
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected RequestBuilder selectRequestMethod(Request request) {
String method = request.getMethod();
if (method == null || method.equalsIgnoreCase(HttpConstant.Method.GET)) {
//default get
return RequestBuilder.get();
} else if (method.equalsIgnoreCase(HttpConstant.Method.POST)) {
RequestBuilder requestBuilder = RequestBuilder.post();
NameValuePair[] nameValuePair = (NameValuePair[]) request.getExtra("nameValuePair");
if (nameValuePair != null && nameValuePair.length > 0) {
requestBuilder.addParameters(nameValuePair);
}
return requestBuilder;
} else if (method.equalsIgnoreCase(HttpConstant.Method.HEAD)) {
return RequestBuilder.head();
} else if (method.equalsIgnoreCase(HttpConstant.Method.PUT)) {
return RequestBuilder.put();
} else if (method.equalsIgnoreCase(HttpConstant.Method.DELETE)) {
return RequestBuilder.delete();
} else if (method.equalsIgnoreCase(HttpConstant.Method.TRACE)) {
return RequestBuilder.trace();
}
throw new IllegalArgumentException("Illegal HTTP Method " + method);
}
示例4: buildGetRequest
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected HttpUriRequest buildGetRequest(String apiCall, List<NameValuePair> nameValuePairs) {
RequestBuilder requestBuilder = RequestBuilder.get(String.format(URL_CONCAT, getBaseUrl(), apiCall));
requestBuilder = addHeaders(requestBuilder);
for (NameValuePair nameValuePair : nameValuePairs) {
requestBuilder.addParameter(nameValuePair);
}
return requestBuilder.build();
}
示例5: buildTokenAuthURI
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
static URI buildTokenAuthURI(final String clientId, final String authRedirect, final String... authScopes) {
final RequestBuilder rb = RequestBuilder.get(BASE_URL_TOKEN_AUTH);
rb.addParameter("response_type", "token");
rb.addParameter("client_id", clientId);
rb.addParameter("redirect_uri", authRedirect);
rb.addParameter("scope", String.join(" ", authScopes));
return rb.build().getURI();
}
示例6: get
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
/**
* Executes a GET request against the partner service.
*
* @return The GET response.
* @throws PartnerException
*/
@Override
public TResponse get()
{
RequestBuilder request = RequestBuilder.get( this.buildPartnerServiceApiUri() );
return this.send( request );
}
示例7: getFileContent
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
/***
* Executes a file content request against the partner service.
*
* @return: The file content stream.
*/
public InputStream getFileContent()
{
try
{
// ensure the credentials are not expired
this.validateCredentials();
RetryableHttpCall retryableHttpCall = new RetryableHttpCall();
CloseableHttpClient httpClient = buildHttpClient();
CloseableHttpResponse response;
try
{
RequestBuilder request = RequestBuilder.get( this.buildPartnerServiceApiUri() );
response = retryableHttpCall.execute( httpClient, request.build() );
}
catch ( IOException e )
{
throw new PartnerException( e.getMessage(), this.requestContext, PartnerErrorCategory.NOT_SPECIFIED, e );
}
if ( response.getStatusLine().getStatusCode() < 400 )
{
return response.getEntity().getContent() == null ? null : response.getEntity().getContent();
}
else
{
// handle the failure according to the configured policy
throw this.getErrorHandler().handleFailedResponse( response, this.requestContext );
}
}
catch ( Exception error )
{
throw new PartnerException( error.getMessage(), error );
}
}
示例8: listLogicalNets
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listLogicalNets()
{
RequestBuilder requestBuilder = RequestBuilder.get();
addCommonHeaders(requestBuilder);
requestBuilder.setUri(String.format(LOGICAL_NETS, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber()));
return requestBuilder;
}
示例9: run
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
@Override
public void run(Webhook webhook, String login, String email, String name, String subject, String content) {
SimpleWebhookApp webhookApp = (SimpleWebhookApp) webhook.getWebhookApp();
String method = webhookApp.getMethod();
String uri = webhookApp.getUri();
String authorization = webhookApp.getAuthorization();
HttpClient httpClient = HttpClientBuilder.create().build();
HttpUriRequest request;
try {
switch (method) {
case "POST":
request = new HttpPost(uri);
((HttpPost) request).setEntity(getEntity(login, email, name, subject, content));
break;
case "PUT":
request = new HttpPut(uri);
((HttpPut) request).setEntity(getEntity(login, email, name, subject, content));
break;
case "GET":
RequestBuilder requestBuilder = RequestBuilder.get(uri);
request = addGetParams(requestBuilder, login, email, name, subject, content);
break;
default:
LOGGER.log(Level.SEVERE, "Unsupported method " + method);
return;
}
request.addHeader("authorization", authorization);
HttpResponse response = httpClient.execute(request);
try (InputStream is = response.getEntity().getContent()) {
String s = ConverterUtils.inputStreamToString(is);
LOGGER.log(Level.INFO, "Webhook response status " + response.getStatusLine() + " \n\t " + s);
}
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, null, ex);
} finally {
LOGGER.log(Level.SEVERE, "Webhook runner terminated");
}
}
示例10: createRequestBuilder
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected RequestBuilder createRequestBuilder() {
return RequestBuilder.get();
}
示例11: get
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected RequestBuilder get(final URIBuilder uri) {
return RequestBuilder.get(build(uri));
}
示例12: listVirtualDisks
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVirtualDisks(){
RequestBuilder requestBuilder = RequestBuilder.get();
addCommonHeaders(requestBuilder);
requestBuilder.setUri(String.format(LIST_VOLUMES, this.provider.getContext().getCloud().getEndpoint(), this.provider.getContext().getAccountNumber()));
return requestBuilder;
}
示例13: listVMsWithVDD
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVMsWithVDD(){
RequestBuilder requestBuilder = RequestBuilder.get();
addCommonHeaders(requestBuilder);
requestBuilder.setUri(String.format(LIST_VMS_WITH_VDD, this.provider.getContext().getCloud().getEndpoint(), this.provider.getContext().getAccountNumber()));
return requestBuilder;
}
示例14: listVirtualMachines
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVirtualMachines(){
RequestBuilder requestBuilder = RequestBuilder.get();
addCommonHeaders(requestBuilder);
requestBuilder.setUri(String.format(LIST_VM_RESOURCES, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber()));
return requestBuilder;
}
示例15: listVirtualMachineNetAdapters
import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVirtualMachineNetAdapters(String vmId, String stampId) {
RequestBuilder requestBuilder = RequestBuilder.get();
addCommonHeaders(requestBuilder);
requestBuilder.setUri(String.format(VM_NETWORK_ADAPTERS, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber(), stampId, vmId));
return requestBuilder;
}