Package org.apache.http.impl.client

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


        // configured to use it with authentication
        if (defaultHttpClient != null && (auth == null || useDefaultClientWithAuthentication))
            return defaultHttpClient;

        // Otherwise use a fresh client each time
        return new SystemDefaultHttpClient();
    }
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

        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

            // Accept
            if ( acceptHeader != null )
                httpget.addHeader(HttpNames.hAccept, acceptHeader) ;
           
            // Execute
            HttpClient httpclient = new SystemDefaultHttpClient();
            HttpResponse response = httpclient.execute(httpget) ;
            // Handle response
            httpResponse(id, response, baseIRI, handlers) ;
            httpclient.getConnectionManager().shutdown();
        } catch (IOException ex) { IO.exception(ex) ; }
    }
View Full Code Here

            // Accept
            if ( acceptHeader != null )
                httpget.addHeader(HttpNames.hAccept, acceptHeader) ;
           
            // Execute
            HttpClient httpclient = new SystemDefaultHttpClient();        // Pool?
            HttpResponse response = httpclient.execute(httpget) ;
           
            // Response
            StatusLine statusLine = response.getStatusLine() ;
            if ( statusLine.getStatusCode() == 404 )
            {
                log.debug(format("[%d] %s %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                return null ;
            }
            if ( statusLine.getStatusCode() >= 400 )
            {
                log.debug(format("[%d] %s %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                throw new HttpException(statusLine.getStatusCode()+" "+statusLine.getReasonPhrase()) ;
            }
   
            HttpEntity entity = response.getEntity() ;
            if ( entity == null )
            {
                // No content in the return.  Probably a mistake, but not guaranteed.
                if ( log.isDebugEnabled() )
                    log.debug(format("[%d] %d %s :: (empty)",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                return null ;
            }
               
            MediaType mt = MediaType.create(entity.getContentType().getValue()) ;
            if ( log.isDebugEnabled() )
                log.debug(format("[%d] %d %s :: %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase() , mt)) ;
               
            return new TypedInputStreamHttp(entity.getContent(), mt,
                                       httpclient.getConnectionManager()) ;
        }
        catch (IOException ex) { IO.exception(ex) ; return null ; }
    }
View Full Code Here

    /** Simple GET - no content negotiation */
    public static String execHttpGet(String url)
    {
        HttpUriRequest httpGet = new HttpGet(url) ;
        HttpClient httpclient = new SystemDefaultHttpClient() ;
        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
            HttpClient httpclient = new SystemDefaultHttpClient();
            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())) ;

            HttpClient httpclient = new SystemDefaultHttpClient();
            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) ;
            HttpClient httpclient = new SystemDefaultHttpClient();
            HttpResponse response = httpclient.execute(httpput) ;
            httpResponse(id, response, baseIRI, null) ;
            httpclient.getConnectionManager().shutdown();
        } catch (IOException ex) { IO.exception(ex) ; }
    }
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
          protected ClientConnectionManager createClientConnectionManager() {
              PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
                      SchemeRegistryFactory.createSystemDefault());
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.