Beispiel #1
0
 public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
   Args.notNull(cookie, "Cookie");
   Args.notNull(origin, "Cookie origin");
   for (CookieAttributeHandler validate : getAttribHandlers()) {
     validate.validate(cookie, origin);
   }
 }
 public RedirectExec(ClientExecChain clientexecchain, HttpRoutePlanner httprouteplanner, RedirectStrategy redirectstrategy)
 {
     log = new HttpClientAndroidLog(getClass());
     Args.notNull(clientexecchain, "HTTP client request executor");
     Args.notNull(httprouteplanner, "HTTP route planner");
     Args.notNull(redirectstrategy, "HTTP redirect strategy");
     requestExecutor = clientexecchain;
     routePlanner = httprouteplanner;
     redirectStrategy = redirectstrategy;
 }
Beispiel #3
0
 public boolean match(Cookie cookie, CookieOrigin origin) {
   Args.notNull(cookie, "Cookie");
   Args.notNull(origin, "Cookie origin");
   for (CookieAttributeHandler match : getAttribHandlers()) {
     if (!match.match(cookie, origin)) {
       return false;
     }
   }
   return true;
 }
 public static HttpCoreContext adapt(HttpContext httpcontext) {
   Args.notNull(httpcontext, "HTTP context");
   if (httpcontext instanceof HttpCoreContext) {
     return (HttpCoreContext) httpcontext;
   } else {
     return new HttpCoreContext(httpcontext);
   }
 }
 public void sendResponseHeader(HttpResponse httpresponse) throws HttpException, IOException {
   Args.notNull(httpresponse, "HTTP response");
   ensureOpen();
   responseWriter.write(httpresponse);
   onResponseSubmitted(httpresponse);
   if (httpresponse.getStatusLine().getStatusCode() >= 200) {
     incrementResponseCount();
   }
 }
 public Object getAttribute(String s, Class class1) {
   Args.notNull(class1, "Attribute class");
   s = ((String) (getAttribute(s)));
   if (s == null) {
     return null;
   } else {
     return class1.cast(s);
   }
 }
 public void sendResponseEntity(HttpResponse httpresponse) throws HttpException, IOException {
   Args.notNull(httpresponse, "HTTP response");
   ensureOpen();
   HttpEntity httpentity = httpresponse.getEntity();
   if (httpentity == null) {
     return;
   } else {
     httpresponse = prepareOutput(httpresponse);
     httpentity.writeTo(httpresponse);
     httpresponse.close();
     return;
   }
 }
Beispiel #8
0
 public final void put(HttpHost host, AuthScheme authScheme) {
   Args.notNull(host, "HTTP host");
   if (authScheme != null) {
     if (authScheme instanceof Serializable) {
       try {
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(buf);
         out.writeObject(authScheme);
         out.close();
         this.map.put(getKey(host), buf.toByteArray());
       } catch (IOException ex) {
         if (this.log.warnEnabled) {
           this.log.warn("Unexpected I/O error while serializing auth scheme", ex);
         }
       }
     } else if (this.log.debugEnabled) {
       this.log.debug("Auth scheme " + authScheme.getClass() + " is not serializable");
     }
   }
 }
Beispiel #9
0
 public final AuthScheme get(HttpHost host) {
   Args.notNull(host, "HTTP host");
   byte[] bytes = (byte[]) this.map.get(getKey(host));
   if (bytes == null) {
     return null;
   }
   try {
     ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
     AuthScheme authScheme = (AuthScheme) in.readObject();
     in.close();
     return authScheme;
   } catch (IOException ex) {
     if (this.log.warnEnabled) {
       this.log.warn("Unexpected I/O error while de-serializing auth scheme", ex);
     }
     return null;
   } catch (ClassNotFoundException ex2) {
     if (this.log.warnEnabled) {
       this.log.warn("Unexpected error while de-serializing auth scheme", ex2);
     }
     return null;
   }
 }
 public BasicRequestLine(String s, String s1, ProtocolVersion protocolversion) {
   method = (String) Args.notNull(s, "Method");
   uri = (String) Args.notNull(s1, "URI");
   protoversion = (ProtocolVersion) Args.notNull(protocolversion, "Version");
 }
Beispiel #11
0
 public final void remove(HttpHost host) {
   Args.notNull(host, "HTTP host");
   this.map.remove(getKey(host));
 }
    public CloseableHttpResponse execute(HttpRoute httproute, HttpRequestWrapper httprequestwrapper, HttpClientContext httpclientcontext, HttpExecutionAware httpexecutionaware)
        throws IOException, HttpException
    {
        Object obj;
        CloseableHttpResponse closeablehttpresponse;
        int j;
        Args.notNull(httproute, "HTTP route");
        Args.notNull(httprequestwrapper, "HTTP request");
        Args.notNull(httpclientcontext, "HTTP context");
        obj = httpclientcontext.getRedirectLocations();
        if (obj != null)
        {
            ((List) (obj)).clear();
        }
        RequestConfig requestconfig = httpclientcontext.getRequestConfig();
        int i;
        if (requestconfig.getMaxRedirects() > 0)
        {
            i = requestconfig.getMaxRedirects();
        } else
        {
            i = 50;
        }
        obj = httprequestwrapper;
        j = 0;
_L1:
        closeablehttpresponse = requestExecutor.execute(httproute, ((HttpRequestWrapper) (obj)), httpclientcontext, httpexecutionaware);
        if (!requestconfig.isRedirectsEnabled() || !redirectStrategy.isRedirected(((HttpRequest) (obj)), closeablehttpresponse, httpclientcontext))
        {
            break MISSING_BLOCK_LABEL_507;
        }
        if (j >= i)
        {
            java.net.URI uri;
            HttpHost httphost;
            AuthScheme authscheme;
            try
            {
                throw new RedirectException((new StringBuilder()).append("Maximum redirects (").append(i).append(") exceeded").toString());
            }
            // Misplaced declaration of an exception variable
            catch (HttpRoute httproute)
            {
                closeablehttpresponse.close();
                throw httproute;
            }
            // Misplaced declaration of an exception variable
            catch (HttpRoute httproute)
            {
                closeablehttpresponse.close();
                throw httproute;
            }
            // Misplaced declaration of an exception variable
            catch (HttpRoute httproute) { }
            break MISSING_BLOCK_LABEL_457;
        }
        j++;
        obj = redirectStrategy.getRedirect(((HttpRequest) (obj)), closeablehttpresponse, httpclientcontext);
        if (!((HttpRequest) (obj)).headerIterator().hasNext())
        {
            ((HttpRequest) (obj)).setHeaders(httprequestwrapper.getOriginal().getAllHeaders());
        }
        obj = HttpRequestWrapper.wrap(((HttpRequest) (obj)));
        if (obj instanceof HttpEntityEnclosingRequest)
        {
            RequestEntityProxy.enhance((HttpEntityEnclosingRequest)obj);
        }
        uri = ((HttpRequestWrapper) (obj)).getURI();
        httphost = URIUtils.extractHost(uri);
        if (httphost != null)
        {
            break MISSING_BLOCK_LABEL_298;
        }
        throw new ProtocolException((new StringBuilder()).append("Redirect URI does not specify a valid host name: ").append(uri).toString());
        if (httproute.getTargetHost().equals(httphost))
        {
            break MISSING_BLOCK_LABEL_375;
        }
        httproute = httpclientcontext.getTargetAuthState();
        if (httproute == null)
        {
            break MISSING_BLOCK_LABEL_332;
        }
        log.debug("Resetting target auth state");
        httproute.reset();
        httproute = httpclientcontext.getProxyAuthState();
        if (httproute == null)
        {
            break MISSING_BLOCK_LABEL_375;
        }
        authscheme = httproute.getAuthScheme();
        if (authscheme == null)
        {
            break MISSING_BLOCK_LABEL_375;
        }
        if (authscheme.isConnectionBased())
        {
            log.debug("Resetting proxy auth state");
            httproute.reset();
        }
        httproute = routePlanner.determineRoute(httphost, ((HttpRequest) (obj)), httpclientcontext);
        if (log.isDebugEnabled())
        {
            log.debug((new StringBuilder()).append("Redirecting to '").append(uri).append("' via ").append(httproute).toString());
        }
        EntityUtils.consume(closeablehttpresponse.getEntity());
        closeablehttpresponse.close();
          goto _L1
 protected final CloseableHttpResponse m12027a(
     HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext) {
   HttpContext httpContext2;
   CloseableHttpResponse a;
   HttpRoute a2;
   Args.m12722a((Object) httpRequest, "HTTP request");
   synchronized (this) {
     HttpContext c = m12035c();
     if (httpContext == null) {
       httpContext2 = c;
     } else {
       Object defaultedHttpContext = new DefaultedHttpContext(httpContext, c);
     }
     HttpParams a3 = m12029a(httpRequest);
     httpContext2.m11529a("http.request-config", HttpClientParamConfig.m11524a(a3));
     RequestDirector a4 =
         m12026a(
             m12051s(), m12050r(), m12056x(), m12057y(), m12023F(), m12017I(), m12058z(),
             m12018A(), m12019B(), m12020C(), m12024G(), a3);
     HttpRoutePlanner F = m12023F();
     ConnectionBackoffStrategy u = m12053u();
     BackoffManager w = m12055w();
   }
   if (u == null || w == null) {
     a = CloseableHttpResponseProxy.m12097a(a4.m11474a(httpHost, httpRequest, httpContext2));
   } else {
     HttpHost httpHost2;
     if (httpHost != null) {
       httpHost2 = httpHost;
     } else {
       httpHost2 = (HttpHost) m12029a(httpRequest).m12084a("http.default-host");
     }
     try {
       a2 = F.m11701a(httpHost2, httpRequest, httpContext2);
       a = CloseableHttpResponseProxy.m12097a(a4.m11474a(httpHost, httpRequest, httpContext2));
       if (u.m11465a((HttpResponse) a)) {
         w.m11463a(a2);
       } else {
         w.m11464b(a2);
       }
     } catch (Throwable e) {
       if (u.m11466a(e)) {
         w.m11463a(a2);
       }
       throw e;
     } catch (Throwable e2) {
       if (u.m11466a(e2)) {
         w.m11463a(a2);
       }
       if (e2 instanceof HttpException) {
         throw ((HttpException) e2);
       } else if (e2 instanceof IOException) {
         throw ((IOException) e2);
       } else {
         throw new UndeclaredThrowableException(e2);
       }
     } catch (Throwable e22) {
       throw new ClientProtocolException(e22);
     }
   }
   return a;
 }
 public void receiveRequestEntity(HttpEntityEnclosingRequest httpentityenclosingrequest)
     throws HttpException, IOException {
   Args.notNull(httpentityenclosingrequest, "HTTP request");
   ensureOpen();
   httpentityenclosingrequest.setEntity(prepareInput(httpentityenclosingrequest));
 }
 public void process(HttpRequest httprequest, HttpContext httpcontext)
     throws HttpException, IOException
 {
     Args.notNull(httprequest, "HTTP request");
     if (!httprequest.getRequestLine().getMethod().equalsIgnoreCase("CONNECT")) goto _L2; else goto _L1