Package org.apache.http.entity

Examples of org.apache.http.entity.InputStreamEntity


    public static void execHttpPost(String url, String contentType,
                                    InputStream input, long length,
                                    String acceptType, Map<String, HttpResponseHandler> handlers)
    {
       
        InputStreamEntity e = new InputStreamEntity(input, length) ;
        e.setContentType(contentType) ;
        e.setContentEncoding("UTF-8") ;
        execHttpPost(url, e, acceptType, handlers, null) ;
    }
View Full Code Here


    }
   
    /** Execute an HTTP PUT operation */
    public static void execHttpPut(String url, String contentType, InputStream input, long length, HttpContext httpContext)
    {
        InputStreamEntity e = new InputStreamEntity(input, length) ;
        e.setContentType(contentType) ;
        e.setContentEncoding("UTF-8") ;
        try { execHttpPut(url, e, httpContext) ; }
        finally { closeEntity(e) ; }
    }
View Full Code Here

            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
View Full Code Here

         apacheRequest.setEntity(Entity);
      } else {
         InputStream inputStream = payload.getInput();
         if (payload.getContentMetadata().getContentLength() == null)
            throw new IllegalArgumentException("you must specify size when content is an InputStream");
         InputStreamEntity entity = new InputStreamEntity(inputStream, payload.getContentMetadata().getContentLength());
         entity.setContentType(payload.getContentMetadata().getContentType());
         apacheRequest.setEntity(entity);
      }
     
      // TODO Reproducing old behaviour exactly; ignoring Content-Type, Content-Length and Content-MD5
      Set<String> desiredHeaders = ImmutableSet.of("Content-Disposition", "Content-Encoding", "Content-Language", "Expires");
View Full Code Here

            ClonedInputStream cis = new ClonedInputStream(is);
            is = cis;
            copy = cis.getOutput();
        }

        inputStreamEntity = new InputStreamEntity(is, length);
    }
View Full Code Here

            AbstractHttpEntity entity = null;
            // Any value set using setValueAsStream() has precedent over value
            // set using setValue()
            if (valueStream != null) {
                if (valueStreamLength != null && valueStreamLength >= 0) {
                    entity = new InputStreamEntity(valueStream, valueStreamLength);
                } else {
                    // since apache http client 4.1 no longer supports buffering stream entities, but we can't change API
                    // behaviour, here we have to buffer the whole content
                    entity = new ByteArrayEntity(ClientUtils.bufferStream(valueStream));
                }
View Full Code Here

            }

            public HttpRequest submitRequest( HttpContext context ) {
                HttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
                post.setHeader( "Connection", "Close" );
                post.setEntity(new InputStreamEntity(producer, 1));
                return post;
            }

            public void handleResponse(final HttpResponse response, final HttpContext context) {
            }
View Full Code Here

                params);
        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        InputStream instream = Mockito.mock(InputStream.class);
        InputStreamEntity entity = new InputStreamEntity(instream, -1);
        request.setEntity(entity);

        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
View Full Code Here

        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
        InputStream instream = Mockito.mock(InputStream.class);
        InputStreamEntity entity = new InputStreamEntity(instream, -1);
        request.setEntity(entity);

        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse resp100 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(resp100);
View Full Code Here

        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
        InputStream instream = Mockito.mock(InputStream.class);
        InputStreamEntity entity = new InputStreamEntity(instream, -1);
        request.setEntity(entity);

        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(response);
View Full Code Here

TOP

Related Classes of org.apache.http.entity.InputStreamEntity

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.