Examples of HttpResponse


Examples of org.jboss.netty.handler.codec.http.HttpResponse

    private void writeResponse(MessageEvent e) {
        // Decide whether to close the connection or not.
        boolean keepAlive = isKeepAlive(request);

        // Build the response object.
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
        response.setContent(ChannelBuffers.copiedBuffer(buf.toString(), CharsetUtil.UTF_8));
        response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");

        if (keepAlive) {
            // Add 'Content-Length' header only for a keep-alive connection.
            response.setHeader(CONTENT_LENGTH, response.getContent().readableBytes());
        }

        // Encode the cookie.
        String cookieString = request.getHeader(COOKIE);
        if (cookieString != null) {
            CookieDecoder cookieDecoder = new CookieDecoder();
            Set<Cookie> cookies = cookieDecoder.decode(cookieString);
            if(!cookies.isEmpty()) {
                // Reset the cookies if necessary.
                CookieEncoder cookieEncoder = new CookieEncoder(true);
                for (Cookie cookie : cookies) {
                    cookieEncoder.addCookie(cookie);
                }
                response.addHeader(SET_COOKIE, cookieEncoder.encode());
            }
        }

        // Write the response.
        ChannelFuture future = e.getChannel().write(response);
View Full Code Here

Examples of org.jboss.resteasy.spi.HttpResponse

            // made it warn so that people can filter this.
            logger.warn("Failed to parse request.", e);
            return;
         }

         HttpResponse theResponse = responseFactory.createResteasyHttpResponse(response);
         HttpRequest in = requestFactory.createResteasyHttpRequest(httpMethod, request, headers, uriInfo, theResponse, response);

         try
         {
            ResteasyProviderFactory.pushContext(HttpServletRequest.class, request);
View Full Code Here

Examples of org.jboss.soa.esb.http.HttpResponse

            return new String[0] ;
        }
    }

    private void attachResponseDetails(Message message, HttpMethodBase method, int responseCode) {
        HttpResponse response = new HttpResponse(responseCode);
        Properties properties = message.getProperties();

        response.setEncoding(method.getResponseCharSet());
        response.setLength(method.getResponseContentLength());

        Header[] responseHeaders = method.getResponseHeaders();
        for(Header responseHeader : responseHeaders) {
          String name = responseHeader.getName();
          String value = responseHeader.getValue();
            response.addHeader(new org.jboss.soa.esb.http.HttpHeader(name, value));
            // JBESB-2511
            new ResponseHeader(name, value).setPropertyNameThis(properties);
        }
        // JBESB-2761
        if (httpResponseStatusEnabled) {
          ResponseStatus.setHttpProperties(properties, responseCode, method.getStatusLine().getReasonPhrase());
        }
       
        response.setResponse(message);
    }
View Full Code Here

Examples of org.jclouds.http.HttpResponse

               .addHeader("Accept", "*/*")
               .addHeader("x-vcloud-authorization", token)
               .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + token)
               .build();

      HttpResponse listResponse = HttpResponse.builder()
               .statusCode(200)
               .payload(payloadFromResourceWithContentType("/org/orglist.xml", ORG_LIST + ";version=1.5"))
               .build();
     
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, list, listResponse);
View Full Code Here

Examples of org.jnegre.redpill.HttpResponse

        model.setValueAt(host, s.getId(), 4);
        //resource
        model.setValueAt(r.getRelativeUrl(), s.getId(), 5);
      }
      public void onResponse(Session s) {
        HttpResponse r = s.getResponse();
        model.setValueAt(ContentTypeHelper.getImageIcon(r.getHeaders().getHeader("Content-type")), s.getId(), 0);
        model.setValueAt(r.getStatusCode(), s.getId(), 2);
      }
    });
   
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
      public void valueChanged(ListSelectionEvent e) {
View Full Code Here

Examples of org.jwall.web.http.HttpResponse

            }

            if( header.isChunked() ){
                state = STATE_READING_CHUNKS;
                chunkState = READING_CHUNK_HEADER;
                return new HttpResponse( header, new byte[0] );
            }

            if( header.isConnectionCloseSet() && header.getHeader( HttpHeader.CONTENT_LENGTH ) == null ){
                log.trace( "{} Switching to STATE_CLOSE_CONNECTION", this );
                state = STATE_CLOSE_CONNECTION;
            }
           
           
            if( header.getContentLength() == 0 ){
              state = STATE_READING_HEADER;
              log.debug( "Readirect or the like, with no content, reading header completed!" );
              return new HttpResponse( header, new byte[0] );
            }
           
        }

        if( header == null )
            throw new ProtocolException("No header available, though state shows being AFTER reading-header...");

        if( header != null && state == STATE_CLOSE_CONNECTION ){
            //
            // ok, the server closes the connection, thus the body contains all data
            // that will be sent until we read 0/EOF bytes...
            //
            ByteBuffer b = ByteBuffer.allocate( 2 * 1024 ); // we try to read 2k-chunks...
            int bytes = in.read( b );
            if( bytes > 0 ){
                //
                // if we read some bytes these will be saved as chunks, as there
                // MIGHT some more following...
                //
                b.flip();
                chunks.add( b );
                return null;

            } else {
                //
                // as no more bytes can be read, we assume the channel to be empty...
                // the only exception from this is: if we did not read ANY bytes until
                // now, we assume there will at least be some more coming...
                //
                if( chunks.isEmpty() )
                    return new HttpResponse( header, new byte[0] );

                int size = 0;
                for( ByteBuffer bb : chunks )
                    size += bb.limit();

                // no we merge all the stuff we previously read into the final message body:
                //
                ByteBuffer body = ByteBuffer.allocate( size );
                for( ByteBuffer bb : chunks )
                    body.put( bb );

                log.info(this + " Completed reading body: " + size + " bytes read.");
                resNum++;
                return new HttpResponse( header, body.array() );
            }
        }

        if( state == STATE_READING_BODY ){

            if( header.getContentLength() > 0 ){
                ByteBuffer body = readBody( header.getContentLength() );

                if( body != null ){
                    resNum++;
                    return new HttpResponse( header, body.array() );
                }
            }

            if( header.isChunked() )
                state = STATE_READING_CHUNKS;
View Full Code Here

Examples of org.kohsuke.stapler.HttpResponse

    /**
     * Also delete all the workspaces of the configuration, too.
     */
    @Override
    public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
        HttpResponse rsp = super.doDoWipeOutWorkspace();
        for (MatrixConfiguration c : configurations.values())
            c.doDoWipeOutWorkspace();
        return rsp;
    }
View Full Code Here

Examples of org.mmisw.ont.client.util.HttpUtil.HttpResponse

    final String encQuery = URLEncoder.encode(query, "UTF-8");
    urlRequest += "?query=" + encQuery;

    System.out.println("Making request...");
    HttpResponse httpResponse = HttpUtil.httpGet(urlRequest, accept);
    System.out.println("httpResponse = " + httpResponse);

    if (httpResponse.contentType.contains("application/json")) {
      _showJson(httpResponse.body);
    }
View Full Code Here

Examples of org.mockserver.model.HttpResponse

    @Test
    public void clientCanCallServer() {
        // then
        // - in http
        assertEquals(
                new HttpResponse()
                        .withStatusCode(HttpStatusCode.OK_200.code())
                        .withBody("test_initializer_response_body"),
                makeRequest(
                        new HttpRequest()
                                .withMethod("POST")
                                .withURL("http://localhost:" + SERVER_HTTP_PORT + "/test_initializer_path")
                                .withBody("test_initializer_request_body")
                )
        );
        // - in https
        assertEquals(
                new HttpResponse()
                        .withStatusCode(HttpStatusCode.OK_200.code())
                        .withBody("test_initializer_response_body"),
                makeRequest(
                        new HttpRequest()
                                .withMethod("POST")
View Full Code Here

Examples of org.mortbay.http.HttpResponse

                                             EndpointReferenceType decoupledResponseEndpoint)
        throws IOException {
        OutputStreamMessageContext outputContext = null;
        HttpRequest request =
            (HttpRequest)context.get(HTTPServerInputStreamContext.HTTP_REQUEST);
        HttpResponse response =
            (HttpResponse)context.get(HTTPServerInputStreamContext.HTTP_RESPONSE);
        if (response != null) {
            outputContext = new HTTPServerRebasedOutputStreamContext(context, request, response);
            context.put(HTTPServerInputStreamContext.HTTP_RESPONSE, decoupledResponseEndpoint);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.