Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.SystemDefaultHttpClient


    /** Simple GET - no content negotiation */
    public static String execHttpGet(String url, HttpContext httpContext)
    {
        HttpUriRequest httpGet = new HttpGet(url) ;
        DefaultHttpClient httpclient = new SystemDefaultHttpClient() ;
        applyAuthentication(httpclient, url, httpContext);
        try {
            HttpResponse response = httpclient.execute(httpGet) ;
            int responseCode = response.getStatusLine().getStatusCode() ;
            String responseMessage = response.getStatusLine().getReasonPhrase() ;
            if ( 200 != responseCode )
                throw JenaHttpException.create(responseCode, responseMessage) ;   
            HttpEntity entity = response.getEntity() ;
View Full Code Here


           
            if ( provider.getContentType() == null )
                log.debug(format("[%d] No content type")) ;

            // Execute
            DefaultHttpClient httpclient = new SystemDefaultHttpClient();
            applyAuthentication(httpclient, url, context);
            httppost.setEntity(provider) ;
            HttpResponse response = httpclient.execute(httppost, context) ;
            httpResponse(id, response, baseIRI, handlers) ;
           
            httpclient.getConnectionManager().shutdown();
        } catch (IOException ex) { IO.exception(ex) ; }
        finally { closeEntity(provider) ; }
    }
View Full Code Here

            HttpPost httppost = new HttpPost(requestURI);
            httppost.setEntity(convertFormParams(params));
            if ( log.isDebugEnabled() )
                log.debug(format("[%d] %s %s",id ,httppost.getMethod(),httppost.getURI().toString())) ;

            DefaultHttpClient httpclient = new SystemDefaultHttpClient();
            applyAuthentication(httpclient, url, httpContext);
            HttpResponse response = httpclient.execute(httppost, httpContext) ;
            httpResponse(id, response, baseIRI, handlers) ;
            httpclient.getConnectionManager().shutdown();
        } catch (IOException ex) { IO.exception(ex) ; }
    }
View Full Code Here

            HttpPut httpput = new HttpPut(requestURI);
            if ( log.isDebugEnabled() )
                log.debug(format("[%d] %s %s",id , httpput.getMethod(), httpput.getURI().toString())) ;
           
            httpput.setEntity(entity) ;
            DefaultHttpClient httpclient = new SystemDefaultHttpClient();
            applyAuthentication(httpclient, url, httpContext);
            HttpResponse response = httpclient.execute(httpput) ;
            httpResponse(id, response, baseIRI, null) ;
            httpclient.getConnectionManager().shutdown();
        } catch (IOException ex) { IO.exception(ex) ; }
    }
View Full Code Here

        return h.getValue() ;
    }

    private Graph exec(String targetStr, Graph graphToSend, HttpUriRequest httpRequest, boolean processBody)
    {
        HttpClient httpclient = new SystemDefaultHttpClient(httpParams) ;
       
        if ( graphToSend != null )
        {
            // ??? httpRequest isa Post
            // Impedence mismatch - is there a better way?
            ByteArrayOutputStream out = new ByteArrayOutputStream() ;
            Model model = ModelFactory.createModelForGraph(graphToSend) ;
            model.write(out, "RDF/XML") ;
            byte[] bytes = out.toByteArray() ;
            ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()) ;
            InputStreamEntity reqEntity = new InputStreamEntity(in, bytes.length) ;
            reqEntity.setContentType(WebContent.contentTypeRDFXML) ;
            reqEntity.setContentEncoding(WebContent.charsetUTF8) ;
            HttpEntity entity = reqEntity ;
            ((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ;
        }
        TypedInputStream ts = null ;
        // httpclient.getParams().setXXX
        try {
            HttpResponse response = httpclient.execute(httpRequest) ;

            int responseCode = response.getStatusLine().getStatusCode() ;
            String responseMessage = response.getStatusLine().getReasonPhrase() ;
           
            if ( HttpSC.isRedirection(responseCode) )
View Full Code Here

    }

    try {
   
      // if we got this far, try to actually get the userinfo
      HttpClient httpClient = new SystemDefaultHttpClient();
     
      HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
     
      String userInfoString = null;
     
View Full Code Here

    if (redirectUri != null) {
      form.add("redirect_uri", redirectUri);
    }

    // Handle Token Endpoint interaction
    HttpClient httpClient = new SystemDefaultHttpClient();

    httpClient.getParams().setParameter("http.socket.timeout", new Integer(httpSocketTimeout));

    HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);

    RestTemplate restTemplate;
View Full Code Here

                             cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH),
                             cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND));
    }

    private String waitForHttp(URI uri) {
        SystemDefaultHttpClient client = new SystemDefaultHttpClient();
        client.setHttpRequestRetryHandler(new StandardHttpRequestRetryHandler(3, false));
        HttpContext localContext = new BasicHttpContext();
        HttpUriRequest httpRequest = new HttpHead(uri);
        HttpResponse httpResponse = null;

        httpResponse = head(client, httpRequest, localContext);
View Full Code Here

        this.cookieStores.remove(key);
    }

    public synchronized HttpClient getHttpClient() {
      if (this.httpClient == null) {
            SystemDefaultHttpClient httpClient = new SystemDefaultHttpClient();
            // Provide custom retry handler is necessary
            httpClient.setHttpRequestRetryHandler(new StandardHttpRequestRetryHandler(3, false));
            return this.httpClient = httpClient;
      } else {
        return httpClient;
      }
    }
View Full Code Here

    /**
     * Create an HttpClient that performs connection pooling. This can be used
     * with {@link #setDefaultHttpClient} or provided in the HttpOp calls.
     */
    public static HttpClient createCachingHttpClient() {
        return new SystemDefaultHttpClient() {
            /**
             * See SystemDefaultHttpClient (4.2). This version always sets the
             * connection cache
             */
            @Override
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.SystemDefaultHttpClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.