Package org.apache.http.nio.entity

Examples of org.apache.http.nio.entity.NStringEntity


                    public void run() {
                        // Wait a bit, to make sure this is delayed.
                        try { Thread.sleep(10); } catch(InterruptedException ie) {}
                        // Set the entity after delaying...
                        try {
                            NStringEntity entity = new NStringEntity(content, "US-ASCII");
                            response.setEntity(entity);
                        catch (UnsupportedEncodingException ex) {
                        }
                        trigger.submitResponse(response);
                    }
View Full Code Here


    private Logger getLogger() {
        return LoggingUtils.getLogger(this);
    }

    private HttpEntity createFileNotFoundEntity(final File file) throws Exception {
        final NStringEntity entity = new NStringEntity("<html><body><h1>File '"
                + file.getName() + "' not found</h1></body></html>", UTF8);
        entity.setContentType("text/html; charset=" + UTF8);
        return entity;
    }
View Full Code Here

        entity.setContentType("text/html; charset=" + UTF8);
        return entity;
    }

    private HttpEntity createForbiddenEntity() throws Exception {
        final NStringEntity entity = new NStringEntity(
                "<html><body><h1>Access denied</h1></body></html>", UTF8);
        entity.setContentType("text/html; charset=" + UTF8);
        return entity;
    }
View Full Code Here

                        event.getTemplateContextData());
               
                // write header buffer
                webcontext.getResponse().writeHeaderBuffer();
               
                return new NStringEntity(template, UTF8);
            } else {
                return new NFileEntity(file, contentType);
            }

        } catch (Throwable t) {
View Full Code Here

        if (gzip) {
            //bout = gzippedOut;
            _response.addHeader(IJSONRPCConstants.REQ_HEAD_CONTENTENCODING,
                    IJSONRPCConstants.REQ_HEAD_GZIP);
        }
        final NStringEntity entity = new NStringEntity(new String(bout),
                ICommonConstants.UTF8);
        entity.setContentType(IJSONRPCConstants.RES_CONTENT_TYPE);
        _response.setEntity(gzip
                ? new GzipCompressingEntity(entity)
                : entity);
    }
View Full Code Here

        this.localServer.register("*", new BasicRedirectService(host, port));

        HttpContext context = new BasicHttpContext();

        HttpPost httppost = new HttpPost("/oldlocation/");
        httppost.setEntity(new NStringEntity("stuff"));

        Future<HttpResponse> future = this.httpclient.execute(this.target, httppost, context, null);
        HttpResponse response = future.get();
        Assert.assertNotNull(response);

View Full Code Here

                HttpStatus.SC_SEE_OTHER));

        HttpContext context = new BasicHttpContext();

        HttpPost httppost = new HttpPost("/oldlocation/");
        httppost.setEntity(new NStringEntity("stuff"));

        Future<HttpResponse> future = this.httpclient.execute(this.target, httppost, context, null);
        HttpResponse response = future.get();
        Assert.assertNotNull(response);
View Full Code Here

    public void testEntityEnclosingRequestWithoutExpectContinue() throws Exception {
        State state = new HttpAsyncRequestExecutor.State();
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        request.setEntity(new NStringEntity("stuff"));
        Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(request);

        this.protocolHandler.requestReady(this.conn);

        Mockito.verify(this.exchangeHandler).generateRequest();
View Full Code Here

    public void testResponseContinue() throws Exception {
        State state = new HttpAsyncRequestExecutor.State();
        state.setRequestState(MessageState.ACK_EXPECTED);
        state.setTimeout(1000);
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        request.setEntity(new NStringEntity("stuff"));
        state.setRequest(request);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
View Full Code Here

    @Test
    public void testResponseContinueOutOfSequence() throws Exception {
        State state = new HttpAsyncRequestExecutor.State();
        state.setRequestState(MessageState.COMPLETED);
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        request.setEntity(new NStringEntity("stuff"));
        state.setRequest(request);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);
View Full Code Here

TOP

Related Classes of org.apache.http.nio.entity.NStringEntity

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.