Java Code Examples for org.apache.http.RequestLine#getUri()
The following examples show how to use
org.apache.http.RequestLine#getUri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AopHttpClient.java From ArgusAPM with Apache License 2.0 | 6 votes |
private static HttpRequest handleRequest(HttpHost host, HttpRequest request, NetInfo data) { RequestLine requestLine = request.getRequestLine(); if (requestLine != null) { String uri = requestLine.getUri(); int i = (uri != null) && (uri.length() >= 10) && (uri.substring(0, 10).indexOf("://") >= 0) ? 1 : 0; if ((i == 0) && (uri != null) && (host != null)) { String uriFromHost = host.toURI().toString(); data.setURL(uriFromHost + ((uriFromHost.endsWith("/")) || (uri.startsWith("/")) ? "" : "/") + uri); } else if (i != 0) { data.setURL(uri); } } if (request instanceof HttpEntityEnclosingRequest) { HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) request; if (entityRequest.getEntity() != null) { entityRequest.setEntity(new AopHttpRequestEntity(entityRequest.getEntity(), data)); } return entityRequest; } return request; }
Example 2
Source File: InstrHttpClientBuilderProvider.java From knox with Apache License 2.0 | 6 votes |
@Override public String getNameFor(String name, HttpRequest request) { try { String context = ""; Header header = request.getFirstHeader("X-Forwarded-Context"); if (header != null) { context = header.getValue(); } RequestLine requestLine = request.getRequestLine(); URIBuilder uriBuilder = new URIBuilder(requestLine.getUri()); String resourcePath = InstrUtils.getResourcePath(uriBuilder.removeQuery().build().toString()); return MetricRegistry.name("service", name, context + resourcePath, methodNameString(request)); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
Example 3
Source File: ApacheHttpClientAspect.java From glowroot with Apache License 2.0 | 6 votes |
@OnBefore public static @Nullable TraceEntry onBefore(ThreadContext context, @BindParameter @Nullable HttpHost hostObj, @BindParameter @Nullable HttpRequest request) { if (request == null) { return null; } RequestLine requestLine = request.getRequestLine(); if (requestLine == null) { return null; } String method = requestLine.getMethod(); if (method == null) { method = ""; } else { method += " "; } String host = hostObj == null ? "" : hostObj.toURI(); String uri = requestLine.getUri(); if (uri == null) { uri = ""; } return context.startServiceCallEntry("HTTP", method + Uris.stripQueryString(uri), MessageSupplier.create("http client request: {}{}{}", method, host, uri), timerName); }
Example 4
Source File: TestHttpHandler.java From deprecated-security-advanced-modules with Apache License 2.0 | 5 votes |
@Override public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { RequestLine requestLine = request.getRequestLine(); this.method = requestLine.getMethod(); this.uri = requestLine.getUri(); HttpEntity entity = null; if (request instanceof HttpEntityEnclosingRequest) { entity = ((HttpEntityEnclosingRequest) request).getEntity(); body = EntityUtils.toString(entity, StandardCharsets.UTF_8); } }
Example 5
Source File: UpnpHttpRequestFactory.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public HttpRequest newHttpRequest(final RequestLine requestline) throws MethodNotSupportedException { if (requestline == null) { throw new IllegalArgumentException("Request line may not be null"); } String method = requestline.getMethod(); String uri = requestline.getUri(); return newHttpRequest(method, uri); }
Example 6
Source File: UpnpHttpRequestFactory.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public HttpRequest newHttpRequest(final RequestLine requestline) throws MethodNotSupportedException { if (requestline == null) { throw new IllegalArgumentException("Request line may not be null"); } String method = requestline.getMethod(); String uri = requestline.getUri(); return newHttpRequest(method, uri); }
Example 7
Source File: HttpAsyncRequestExecutorInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { HttpContext context = CONTEXT_LOCAL.get(); CONTEXT_LOCAL.remove(); if (context == null) { return; } final ContextCarrier contextCarrier = new ContextCarrier(); HttpRequestWrapper requestWrapper = (HttpRequestWrapper) context.getAttribute(HttpClientContext.HTTP_REQUEST); HttpHost httpHost = (HttpHost) context.getAttribute(HttpClientContext.HTTP_TARGET_HOST); RequestLine requestLine = requestWrapper.getRequestLine(); String uri = requestLine.getUri(); String operationName = uri.startsWith("http") ? new URL(uri).getPath() : uri; int port = httpHost.getPort(); AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, httpHost.getHostName() + ":" + (port == -1 ? 80 : port)); span.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT); Tags.URL.set(span, requestWrapper.getOriginal().getRequestLine().getUri()); Tags.HTTP.METHOD.set(span, requestLine.getMethod()); SpanLayer.asHttp(span); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); requestWrapper.setHeader(next.getHeadKey(), next.getHeadValue()); } }
Example 8
Source File: ApacheHttpAsyncClientAspect.java From glowroot with Apache License 2.0 | 5 votes |
@OnBefore public static @Nullable AsyncTraceEntry onBefore(ThreadContext context, @BindParameter @Nullable HttpHost hostObj, @BindParameter @Nullable HttpRequest request, @BindParameter ParameterHolder<FutureCallback<HttpResponse>> callback) { if (request == null) { return null; } RequestLine requestLine = request.getRequestLine(); if (requestLine == null) { return null; } String method = requestLine.getMethod(); if (method == null) { method = ""; } else { method += " "; } String host = hostObj == null ? "" : hostObj.toURI(); String uri = requestLine.getUri(); if (uri == null) { uri = ""; } AsyncTraceEntry asyncTraceEntry = context.startAsyncServiceCallEntry("HTTP", method + Uris.stripQueryString(uri), MessageSupplier.create("http client request: {}{}{}", method, host, uri), timerName); callback.set(ExecuteAdvice.createWrapper(context, callback, asyncTraceEntry)); return asyncTraceEntry; }
Example 9
Source File: HttpRequestParcel.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
public HttpRequestParcel(HttpUriRequest request) { RequestLine line = request.getRequestLine(); uri = line.getUri(); method = line.getMethod(); headers = new Bundle(); for (Header header : request.getAllHeaders()) { headers.putString(header.getName(), header.getValue()); } params = new Bundle(); entity = null; files = new Bundle(); }
Example 10
Source File: DispatchRequestFactory.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public HttpRequest newHttpRequest(RequestLine requestLine) throws MethodNotSupportedException { String method = requestLine.getMethod(); String uri = requestLine.getUri(); return this.newHttpRequest(method, uri); }
Example 11
Source File: HttpClient4RequestWrapper.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public String getUrl() { final RequestLine requestLine = this.httpRequest.getRequestLine(); if (requestLine != null) { return requestLine.getUri(); } return null; }
Example 12
Source File: HttpRequestBuilder.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 4 votes |
public HttpRequest newHttpRequest(RequestLine requestLine) throws MethodNotSupportedException { String method = requestLine.getMethod(); String uri = requestLine.getUri(); return newHttpRequest(method, uri); }