Package org.apache.http.entity

Examples of org.apache.http.entity.BasicHttpEntity


        if (expectEntityBody) {
            inputBuffer
                = new SharedInputBuffer(cfg.getBufferSize(), conn, allocator);
            context.setAttribute(RESPONSE_SINK_BUFFER, inputBuffer);

            BasicHttpEntity entity = new BasicHttpEntity();
            if (response.getStatusLine().getProtocolVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);
            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
           
        } else {
View Full Code Here


        boolean forceContentLength = msgContext.isPropertyTrue(
                NhttpConstants.FORCE_HTTP_CONTENT_LENGTH);
        boolean forceContentLengthCopy = msgContext.isPropertyTrue(
                NhttpConstants.COPY_CONTENT_LENGTH_FROM_INCOMING);

        BasicHttpEntity entity = (BasicHttpEntity) response.getEntity();

        MetricsCollector lstMetrics = worker.getServiceHandler().getMetrics();
        try {
            if (forceContentLength) {
                entity.setChunked(false);
                if (forceContentLengthCopy && contentLength > 0) {
                    entity.setContentLength(contentLength);
                } else {
                    setStreamAsTempData(entity, messageFormatter, msgContext, format);
                }
            }
View Full Code Here

        this.uri = new URI(Args.notNull(uri, "uri"));
    }

    private HttpResponse buildFakeResponse(final String errorMessage) {
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
        BasicHttpEntity entity = new BasicHttpEntity();
        entity.setContent(bais);
        entity.setContentLength(0);
        entity.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);

        BasicHttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), 400, "Exception: "
                + errorMessage);
        response.setEntity(entity);
View Full Code Here

        if (httpRequestMethod == null) {
            httpRequestMethod = "POST";
            message.put(Message.HTTP_REQUEST_METHOD, httpRequestMethod);
        }
        final CXFHttpRequest e = new CXFHttpRequest(httpRequestMethod);
        BasicHttpEntity entity = new BasicHttpEntity() {
            public boolean isRepeatable() {
                return e.getOutputStream().retransmitable();
            }
        };
        entity.setChunked(true);
        entity.setContentType((String)message.get(Message.CONTENT_TYPE));
        e.setURI(uri);
       
        e.setEntity(entity);
       
        // Set socket timeout
View Full Code Here

        if (expectEntityBody) {
            inputBuffer
                = new SharedInputBuffer(cfg.getBufferSize(), conn, allocator);
            context.setAttribute(RESPONSE_SINK_BUFFER, inputBuffer);

            BasicHttpEntity entity = new BasicHttpEntity();
            if (response.getStatusLine().getProtocolVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);
            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
           
        } else {
View Full Code Here

                    epr.getAddress() : url.getPath()
                        + (url.getQuery() != null ? "?" + url.getQuery() : ""),
                msgContext.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0) ?
                    HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1);

            BasicHttpEntity entity = new BasicHttpEntity();

            if (msgContext.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0)) {
                setStreamAsTempData(entity);
            } else {
                entity.setChunked(chunked);
                if (!chunked) {
                    setStreamAsTempData(entity);
                }
            }
            ((BasicHttpEntityEnclosingRequest) httpRequest).setEntity(entity);
View Full Code Here

            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
                    final HttpContext context) throws HttpException, IOException {
                BasicHttpEntity entity = new BasicHttpEntity() {

                    @Override
                    public void writeTo(
                            final OutputStream outstream) throws IOException {
                        byte[] tmp = new byte[5];
                        outstream.write(tmp);
                        outstream.flush();
                       
                        // do something comletely ugly in order to trigger
                        // MalformedChunkCodingException
                        DefaultHttpServerConnection conn = (DefaultHttpServerConnection)
                            context.getAttribute(ExecutionContext.HTTP_CONNECTION);
                        try {
                            conn.sendResponseHeader(response);
                        } catch (HttpException ignore) {
                        }
                    }
                   
                } ;
                entity.setChunked(true);
                response.setEntity(entity);
            }
           
        });
       
View Full Code Here

            HttpResponse response = responseFactory.newHttpResponse(
                httpVersion, HttpStatus.SC_OK, context);
            response.setParams(this.params);

            // create a basic HttpEntity using the source channel of the response pipe
            BasicHttpEntity entity = new BasicHttpEntity();
            if (httpVersion.greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);

            // hand off processing of the request to a thread off the pool
            ServerWorker worker = new ServerWorker(cfgCtx, conn, isHttps, metrics, this,
View Full Code Here

      if(!request.getMethod().equalsIgnoreCase(httpMethod))
        throw new IllegalArgumentException(String.format("Expected %s, but was %s", httpMethod, request.getMethod()));

      if(request.getURI().toString().equals(uri)) {
        HttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), 200, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        if(contentLocation != null)
          response.addHeader(new BasicHeader("Content-Location", contentLocation));
        entity.setContentEncoding(charset);
        entity.setContentType(this.contentType);
        entity.setContent(this.body);
        response.setEntity(new BufferedHttpEntity(entity));

        assertParameters(request);
        assertHeaders(request);
View Full Code Here

    public void testRequestsExpecting100ContinueBehaviorShouldSetExpectHeader() throws Exception {
        final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest(
                "POST", "/", HttpVersion.HTTP_1_1);
        post.setHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
        post.setHeader("Content-Length", "128");
        post.setEntity(new BasicHttpEntity());

        final Capture<HttpRequestWrapper> reqCap = new Capture<HttpRequestWrapper>();

        EasyMock.expect(
                mockBackend.execute(
View Full Code Here

TOP

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

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.