public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { if (request == null) { throw new IllegalArgumentException("HTTP request may not be null"); } // Add default headers Collection<?> defHeaders = (Collection<?>) request.getParams().getParameter( ClientPNames.DEFAULT_HEADERS); if (defHeaders != null) { for (Object defHeader : defHeaders) { request.addHeader((Header) defHeader); } } }
target = (HttpHost) request.getParams().getParameter( ClientPNames.DEFAULT_HOST);
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { if (request == null) { throw new IllegalArgumentException("HTTP request may not be null"); } if (!request.containsHeader(HTTP.USER_AGENT)) { String useragent = HttpProtocolParams.getUserAgent(request.getParams()); if (useragent != null) { request.addHeader(HTTP.USER_AGENT, useragent); } } }
/** * Obtains parameters for executing a request. * The default implementation in this class creates a new * {@link ClientParamsStack} from the request parameters * and the client parameters. * <br/> * This method is called by the default implementation of * {@link #execute(HttpHost,HttpRequest,HttpContext)} * to obtain the parameters for the * {@link DefaultRequestDirector}. * * @param req the request that will be executed * * @return the parameters to use */ protected HttpParams determineParams(HttpRequest req) { return new ClientParamsStack (null, getParams(), req.getParams(), null); }
target = (HttpHost) request.getParams().getParameter( ClientPNames.DEFAULT_HOST);
/** * Produces basic authorization header for the given set of {@link Credentials}. * * @param credentials The set of credentials to be used for athentication * @param request The request being authenticated * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials * are not valid or not applicable for this authentication scheme * @throws AuthenticationException if authorization string cannot * be generated due to an authentication failure * * @return a basic authorization string */ public Header authenticate( final Credentials credentials, final HttpRequest request) throws AuthenticationException { if (credentials == null) { throw new IllegalArgumentException("Credentials may not be null"); } if (request == null) { throw new IllegalArgumentException("HTTP request may not be null"); } String charset = AuthParams.getCredentialCharset(request.getParams()); return authenticate(credentials, charset, isProxy()); }
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { if (request == null) { throw new IllegalArgumentException("HTTP request may not be null"); } if (request instanceof HttpEntityEnclosingRequest) { HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity(); // Do not send the expect header if request body is known to be empty if (entity != null && entity.getContentLength() != 0) { ProtocolVersion ver = request.getRequestLine().getProtocolVersion(); if (HttpProtocolParams.useExpectContinue(request.getParams()) && !ver.lessEquals(HttpVersion.HTTP_1_0)) { request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE); } } } }
public RequestWrapper(final HttpRequest request) throws ProtocolException { super(); if (request == null) { throw new IllegalArgumentException("HTTP request may not be null"); } this.original = request; setParams(request.getParams()); // Make a copy of the original URI if (request instanceof HttpUriRequest) { this.uri = ((HttpUriRequest) request).getURI(); this.method = ((HttpUriRequest) request).getMethod(); this.version = null; } else { RequestLine requestLine = request.getRequestLine(); try { this.uri = new URI(requestLine.getUri()); } catch (URISyntaxException ex) { throw new ProtocolException("Invalid request URI: " + requestLine.getUri(), ex); } this.method = requestLine.getMethod(); this.version = request.getProtocolVersion(); } this.execCount = 0; }
String charset = getParameter("charset"); if (charset == null) { charset = AuthParams.getCredentialCharset(request.getParams()); getParameters().put("charset", charset);
ConnRouteParams.getForcedRoute(request.getParams()); if (route != null) return route; ConnRouteParams.getLocalAddress(request.getParams()); HttpHost proxy = (HttpHost) request.getParams().getParameter(ConnRoutePNames.DEFAULT_PROXY); if (proxy == null) { proxy = determineProxy(target, request, context);
int tms = request.getParams().getIntParameter( CoreProtocolPNames.WAIT_FOR_CONTINUE, 2000);
HttpRoute origRoute = determineRoute(target, origWrapper, context); virtualHost = (HttpHost) orig.getParams().getParameter( ClientPNames.VIRTUAL_HOST);
private String handlePingMethodCall(HttpRequest req) { final String callingPeer = (String)req.getParams().getParameter("callingPeer"); if (s_logger.isDebugEnabled()) { s_logger.debug("Handle ping request from " + callingPeer); } return "true"; } }
@SuppressWarnings("deprecation") private void parseRequest(HttpRequest request) throws IOException { if (request instanceof HttpEntityEnclosingRequest) { final HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest)request; final String body = EntityUtils.toString(entityRequest.getEntity()); if (body != null) { final String[] paramArray = body.split("&"); if (paramArray != null) { for (final String paramEntry : paramArray) { final String[] paramValue = paramEntry.split("="); if (paramValue.length != 2) { continue; } final String name = URLDecoder.decode(paramValue[0]); final String value = URLDecoder.decode(paramValue[1]); if (s_logger.isTraceEnabled()) { s_logger.trace("Parsed request parameter " + name + "=" + value); } request.getParams().setParameter(name, value); } } } } }
new DefaultedHttpParams(request.getParams(), this.params));
private String handleDeliverPduMethodCall(HttpRequest req) { final String pduSeq = (String)req.getParams().getParameter("pduSeq"); final String pduAckSeq = (String)req.getParams().getParameter("pduAckSeq"); final String sourcePeer = (String)req.getParams().getParameter("sourcePeer"); final String destPeer = (String)req.getParams().getParameter("destPeer"); final String agentId = (String)req.getParams().getParameter("agentId"); final String gsonPackage = (String)req.getParams().getParameter("gsonPackage"); final String stopOnError = (String)req.getParams().getParameter("stopOnError"); final String pduType = (String)req.getParams().getParameter("pduType"); final ClusterServicePdu pdu = new ClusterServicePdu(); pdu.setSourcePeer(sourcePeer); pdu.setDestPeer(destPeer); pdu.setAgentId(Long.parseLong(agentId)); pdu.setSequenceId(Long.parseLong(pduSeq)); pdu.setAckSequenceId(Long.parseLong(pduAckSeq)); pdu.setJsonPackage(gsonPackage); pdu.setStopOnError("1".equals(stopOnError)); pdu.setPduType(Integer.parseInt(pduType)); manager.OnReceiveClusterServicePdu(pdu); return "true"; }
protected void handleRequest(HttpRequest req, HttpResponse response) { final String method = (String)req.getParams().getParameter("method");
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { if (request == null) { throw new IllegalArgumentException("HTTP request may not be null"); } if (!request.containsHeader(HTTP.USER_AGENT)) { String useragent = HttpProtocolParams.getUserAgent(request.getParams()); if (useragent != null) { request.addHeader(HTTP.USER_AGENT, useragent); } } }