Code example for HttpUriRequest

Methods: setHeader

0
 
    private HttpResponse executeWithAuthRetry(HttpUriRequest httpurirequest, String s, String s1)
        throws ClientProtocolException, IOException, Uploader.UnauthorizedException 
    { 
        long l = SystemClock.elapsedRealtime();
        HttpResponse httpresponse = mHttpClient.execute(httpurirequest);
        MetricsUtils.incrementNetworkOpDuration(SystemClock.elapsedRealtime() - l);
        int i = httpresponse.getStatusLine().getStatusCode();
        if(i == 401 || i == 403)
        { 
            String s2;
            try 
            { 
                s2 = mAuthorizer.getFreshAuthToken(s, "lh2", s1);
                if(s2 == null)
                    throw new Uploader.UnauthorizedException("null auth token"); 
            } 
            catch(OperationCanceledException operationcanceledexception)
            { 
                if(EsLog.isLoggable("iu.UploadsManager", 3)) 
                    Log.d("iu.UploadsManager", "authentication canceled", operationcanceledexception);
                throw new Uploader.UnauthorizedException(operationcanceledexception);
            } 
            catch(IOException ioexception)
            { 
                if(EsLog.isLoggable("iu.UploadsManager", 3)) 
                    Log.d("iu.UploadsManager", "authentication failed", ioexception);
                throw ioexception;
            } 
            catch(AuthenticatorException authenticatorexception)
            { 
                if(EsLog.isLoggable("iu.UploadsManager", 5)) 
                    Log.w("iu.UploadsManager", authenticatorexception);
                throw new Uploader.UnauthorizedException(authenticatorexception);
            } 
            httpurirequest.setHeader("Authorization", (new StringBuilder("GoogleLogin auth=")).append(s2).toString());
            if(EsLog.isLoggable("iu.UploadsManager", 3)) 
                Log.d("iu.UploadsManager", "executeWithAuthRetry: attempt #2");
            long l1 = SystemClock.elapsedRealtime();
            httpresponse = mHttpClient.execute(httpurirequest);
            MetricsUtils.incrementNetworkOpDuration(SystemClock.elapsedRealtime() - l1);
        } 
        return httpresponse;
    }