List of usage examples for org.apache.http.protocol HttpContext removeAttribute
Object removeAttribute(String str);
From source file:org.apache.synapse.transport.passthru.jmx.LatencyCollector.java
/** * Clear all timestamps saved./* ww w. j a v a2 s .c o m*/ * @param context HttpContext */ public static void clearTimestamps(HttpContext context) { if (context == null) { return; } context.removeAttribute(NhttpConstants.REQ_ARRIVAL_TIME); context.removeAttribute(NhttpConstants.REQ_DEPARTURE_TIME); context.removeAttribute(NhttpConstants.RES_HEADER_ARRIVAL_TIME); context.removeAttribute(NhttpConstants.RES_TO_CLIENT_WRITE_START_TIME); context.removeAttribute(NhttpConstants.RES_ARRIVAL_TIME); context.removeAttribute(NhttpConstants.RES_DEPARTURE_TIME); context.removeAttribute(NhttpConstants.REQ_FROM_CLIENT_READ_START_TIME); context.removeAttribute(NhttpConstants.REQ_FROM_CLIENT_READ_END_TIME); context.removeAttribute(NhttpConstants.REQ_TO_BACKEND_WRITE_START_TIME); context.removeAttribute(NhttpConstants.REQ_TO_BACKEND_WRITE_END_TIME); context.removeAttribute(NhttpConstants.RES_FROM_BACKEND_READ_START_TIME); context.removeAttribute(NhttpConstants.RES_FROM_BACKEND_READ_END_TIME); context.removeAttribute(NhttpConstants.RES_TO_CLIENT_WRITE_END_TIME); context.removeAttribute(NhttpConstants.SERVER_WORKER_START_TIME); context.removeAttribute(NhttpConstants.SERVER_WORKER_INIT_TIME); context.removeAttribute(NhttpConstants.CLIENT_WORKER_START_TIME); context.removeAttribute(NhttpConstants.CLIENT_WORKER_INIT_TIME); }
From source file:com.alibaba.openapi.client.rpc.AliNHttpRequstExecutionHandler.java
public void finalizeContext(HttpContext context) { context.removeAttribute(CONTEXT_ATTACHMENT); }
From source file:de.shadowhunt.subversion.internal.AbstractOperation.java
/** * as the Resource can not differ between files and directories each request for an directory (without ending '/') * will result in a redirect (with ending '/'), if another call to a redirected URI occurs a * CircularRedirectException is thrown, as we can't determine the real target we can't prevent this from happening. * Allowing circular redirects globally could lead to live locks on the other hand. Therefore we clear the * redirection cache explicitly./*w w w. jav a 2s . c o m*/ */ final void clearRedirects(final HttpContext context) { context.removeAttribute(HttpClientContext.REDIRECT_LOCATIONS); }
From source file:org.siddhiesb.transport.passthru.connections.HostConnections.java
public void release(NHttpClientConnection conn) { conn.getMetrics().reset();// w ww . j av a2s.com HttpContext ctx = conn.getContext(); ctx.removeAttribute(ExecutionContext.HTTP_REQUEST); ctx.removeAttribute(ExecutionContext.HTTP_RESPONSE); lock.lock(); try { if (busyConnections.remove(conn)) { freeConnections.add(conn); } else { log.error("Attempted to releaseConnection connection not in the busy list"); } } finally { lock.unlock(); } }
From source file:org.jclouds.http.httpnio.pool.NioHttpCommandExecutionHandler.java
public HttpEntityEnclosingRequest submitRequest(HttpContext context) { HttpCommandRendezvous<?> rendezvous = (HttpCommandRendezvous<?>) context.removeAttribute("command"); if (rendezvous != null) { HttpRequest request = rendezvous.getCommand().getRequest(); for (HttpRequestFilter filter : request.getFilters()) { filter.filter(request);// w ww .ja v a 2s .co m } logger.debug("Sending request %s: %s", request.hashCode(), request.getRequestLine()); if (request.getEntity() != null && wire.enabled()) request.setEntity(wire.output(request.getEntity())); HttpEntityEnclosingRequest nativeRequest = NioHttpUtils.convertToApacheRequest(request); HttpUtils.logRequest(headerLog, request, ">>"); return nativeRequest; } return null; }
From source file:org.jclouds.http.httpnio.pool.NioHttpCommandExecutionHandler.java
public void finalizeContext(HttpContext context) { NioHttpCommandConnectionHandle handle = (NioHttpCommandConnectionHandle) context .removeAttribute("command-handle"); if (handle != null) { try {/* w w w . jav a 2s .co m*/ handle.cancel(); } catch (Exception e) { logger.error(e, "Error cancelling handle %1$s", handle); } } }
From source file:org.jclouds.http.httpnio.pool.NioHttpCommandExecutionHandler.java
public void handleResponse(HttpResponse apacheResponse, HttpContext context) throws IOException { NioHttpCommandConnectionHandle handle = (NioHttpCommandConnectionHandle) context .removeAttribute("command-handle"); if (handle != null) { try {//from w w w .j av a2 s.com HttpCommandRendezvous<?> rendezvous = handle.getCommandRendezvous(); HttpCommand command = rendezvous.getCommand(); org.jclouds.http.HttpResponse response = NioHttpUtils.convertToJavaCloudsResponse(apacheResponse); logger.debug("Receiving response %s: %s", response.hashCode(), response.getStatusLine()); HttpUtils.logResponse(headerLog, response, "<<"); if (response.getContent() != null && wire.enabled()) response.setContent(wire.input(response.getContent())); int statusCode = response.getStatusCode(); if (statusCode >= 300) { if (retryHandler.shouldRetryRequest(command, response)) { resubmitQueue.add(rendezvous); } else { errorHandler.handleError(command, response); assert command.getException() != null : "errorHandler should have set an exception!"; rendezvous.setException(command.getException()); } } else { rendezvous.setResponse(response); } } catch (InterruptedException e) { logger.error(e, "interrupted processing response task"); } finally { releaseConnectionToPool(handle); } } else { throw new IllegalStateException( String.format("No command-handle associated with command %1$s", context)); } }
From source file:org.apache.synapse.transport.nhttp.ServerHandler.java
public void closed(final NHttpServerConnection conn) { HttpContext context = conn.getContext(); shutdownConnection(conn, false, null); context.removeAttribute(REQUEST_SINK_BUFFER); context.removeAttribute(RESPONSE_SOURCE_BUFFER); context.removeAttribute(CONNECTION_CREATION_TIME); context.removeAttribute(SERVER_CONNECTION_DEBUG); if (log.isTraceEnabled()) { log.trace(conn + ": Connection closed"); }// ww w. j a va 2 s .c o m metrics.disconnected(); }