本文整理汇总了Java中org.eclipse.jetty.client.HttpRequest类的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest类的具体用法?Java HttpRequest怎么用?Java HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpRequest类属于org.eclipse.jetty.client包,在下文中一共展示了HttpRequest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeMethod
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
HttpRequest request = (HttpRequest)objInst;
ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(request.getURI().getPath(), contextCarrier, request.getHost() + ":" + request.getPort());
span.setComponent(ComponentsDefine.JETTY_CLIENT);
Tags.HTTP.METHOD.set(span, getHttpMethod(request));
Tags.URL.set(span, request.getURI().toString());
SpanLayer.asHttp(span);
CarrierItem next = contextCarrier.items();
HttpFields field = request.getHeaders();
while (next.hasNext()) {
next = next.next();
field.add(next.getHeadKey(), next.getHeadValue());
}
}
示例2: JettyClientCall
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
/**
* Constructor.
*
* @param helper
* The parent HTTP client helper.
* @param method
* The method name.
* @param requestUri
* The request URI.
* @throws IOException
* In case of an I/O error
*/
public JettyClientCall( JettyHttpClientHelper helper, final String method, final String requestUri ) throws IOException
{
super( helper, method, requestUri );
clientHelper = helper;
if( requestUri.startsWith( "http:" ) || requestUri.startsWith( "https:" ) )
{
httpRequest = (HttpRequest) helper.getHttpClient().newRequest( requestUri );
httpRequest.method( method );
setConfidential( httpRequest.getURI().getScheme().equalsIgnoreCase( Protocol.HTTPS.getSchemeName() ) );
}
else
{
throw new IllegalArgumentException( "Only HTTP or HTTPS resource URIs are allowed here" );
}
}
示例3: newHttpRequest
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
@Override
protected HttpRequest newHttpRequest(HttpConversation conversation, URI uri) {
final HttpRequest req = super.newHttpRequest(conversation, uri);
final InstrumentedListener listener = new InstrumentedListener(metricRegistry, nameStrategy);
req.listener(listener);
req.onResponseBegin((response) -> listener.onResponseBegin());
req.onResponseSuccess((result) -> listener.onResponseComplete(null, result));
req.onResponseFailure((x, exn) -> listener.onResponseComplete(exn, x));
return req;
}
示例4: getHttpMethod
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
public String getHttpMethod(HttpRequest request) {
String method = request.getMethod();
if (method == null || method.length() == 0) {
method = "GET";
}
return method;
}
示例5: getHttpMethod
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
public String getHttpMethod(HttpRequest request) {
HttpMethod httpMethod = HttpMethod.GET;
/**
* The method is null if the client using GET method.
*
* @see org.eclipse.jetty.client.HttpRequest#GET(String uri)
* @see org.eclipse.jetty.client.HttpRequest( org.eclipse.jetty.client.HttpClient client, long conversation, java.net.URI uri)
*/
if (request.getMethod() != null) {
httpMethod = request.getMethod();
}
return httpMethod.name();
}
示例6: fixQueryString
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
/**
* <p>
* ライブラリのバグを修正します<br>
* URLにマルチバイト文字が含まれている場合にURLが正しく組み立てられないバグを修正します
* </p>
*/
private static void fixQueryString(Request proxyRequest, String queryString) {
if (!StringUtils.isEmpty(queryString)) {
if (proxyRequest instanceof HttpRequest) {
try {
QUERY_FIELD.set(proxyRequest, queryString);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
}
示例7: newHttpRequest
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
@Override
public HttpRequest newHttpRequest(HttpConversation conversation, URI uri) {
final SalesforceHttpRequest request = new SalesforceHttpRequest(this, conversation, uri);
request.timeout(timeout, TimeUnit.MILLISECONDS);
return request;
}
示例8: copyRequest
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
@Override
public Request copyRequest(HttpRequest oldRequest, URI newURI) {
return super.copyRequest(oldRequest, newURI);
}
示例9: getHttpRequest
import org.eclipse.jetty.client.HttpRequest; //导入依赖的package包/类
/**
* Returns the HTTP request.
*
* @return The HTTP request.
*/
public HttpRequest getHttpRequest()
{
return httpRequest;
}