Examples of HttpRequest

Otherwise, the HTTP request will go directly to the host:
header "Connection" or "Proxy-Connection"
The HttpRequest sets the appropriate connection header to "Keep-Alive" to keep alive the connection to the host or proxy (respectively). By setting the appropriate connection header, the user can control whether the HttpRequest tries to use Keep-Alives.
header "Host"
The HTTP/1.1 protocol requires that the "Host" header be set to the name of the machine being contacted. By default, this is derived from the URL used to construct the HttpRequest, and is set automatically if the user does not set it.
header "Content-Length"
If the user calls getOutputStream and writes some data to it, the "Content-Length" header will be set to the amount of data that has been written at the time that connect is called.
Once all data has been read from the remote host, the underlying socket may be automatically recycled and used again for subsequent requests to the same remote host. If the user is not planning on reading all the data from the remote host, the user should call close to release the socket. Although it happens under the covers, the user should be aware that if an IOException occurs or once data has been read normally from the remote host, close is called automatically. This is to ensure that the minimal number of sockets are left open at any time.

The input stream that getInputStream provides automatically hides whether the remote host is providing HTTP/1.1 "chunked" encoding or regular streaming data. The user can simply read until reaching the end of the input stream, which signifies that all the available data from this request has been read. If reading from a "chunked" source, the data is automatically de-chunked as it is presented to the user. Currently, no access is provided to the underlying raw input stream. @author Colin Stevens (colin.stevens@sun.com) @version 2.5

  • twitter4j.internal.http.HttpRequest

  • Examples of org.jboss.netty.handler.codec.http.HttpRequest

        private final StringBuilder buf = new StringBuilder();

        @Override
        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
            if (!readingChunks) {
                HttpRequest request = this.request = (HttpRequest) e.getMessage();

                if (is100ContinueExpected(request)) {
                    send100Continue(e);
                }

                buf.setLength(0);
                buf.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
                buf.append("===================================\r\n");

                buf.append("VERSION: " + request.getProtocolVersion() + "\r\n");
                buf.append("HOSTNAME: " + getHost(request, "unknown") + "\r\n");
                buf.append("REQUEST_URI: " + request.getUri() + "\r\n\r\n");

                for (Map.Entry<String, String> h: request.getHeaders()) {
                    buf.append("HEADER: " + h.getKey() + " = " + h.getValue() + "\r\n");
                }
                buf.append("\r\n");

                QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
                Map<String, List<String>> params = queryStringDecoder.getParameters();
                if (!params.isEmpty()) {
                    for (Entry<String, List<String>> p: params.entrySet()) {
                        String key = p.getKey();
                        List<String> vals = p.getValue();
                        for (String val : vals) {
                            buf.append("PARAM: " + key + " = " + val + "\r\n");
                        }
                    }
                    buf.append("\r\n");
                }

                if (request.isChunked()) {
                    readingChunks = true;
                } else {
                    ChannelBuffer content = request.getContent();
                    if (content.readable()) {
                        buf.append("CONTENT: " + content.toString(CharsetUtil.UTF_8) + "\r\n");
                    }
                    writeResponse(e);
                }
    View Full Code Here

    Examples of org.jboss.resteasy.spi.HttpRequest

                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);
                ResteasyProviderFactory.pushContext(HttpServletResponse.class, response);
    View Full Code Here

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

                method.setRequestHeader("Content-Type", "text/xml;charset=UTF-8") ;
            }
        }
       
      private void setMappedHttpHeaders(HttpMethodBase method, Message message) {
          HttpRequest request = HttpRequest.getRequest(message);
          Properties properties = message.getProperties();
          for (String headerName : mappedHeaderList) {
            String headerValue = null;
            if (request != null) {
              headerValue = getHttpHeaderValue(request, headerName);
    View Full Code Here

    Examples of org.jclouds.http.HttpRequest

    @Test(groups = { "unit", "user" }, singleThreaded = true, testName = "OrgApiExpectTest")
    public class OrgApiExpectTest extends VCloudDirectorAdminApiExpectTest {

       @Test
       public void testGetOrgList() {
          HttpRequest list = HttpRequest.builder()
                   .method("GET")
                   .endpoint(endpoint + "/org/")
                   .addHeader("Accept", "*/*")
                   .addHeader("x-vcloud-authorization", token)
                   .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + token)
    View Full Code Here

    Examples of org.jnegre.redpill.HttpRequest

        sm.addListener(new SessionManager.Listener(){
          public void onNewSession(Session s) {
            model.addRow(new Object[]{"",s.getId(),"","","",""});
          }
          public void onRequest(Session s) {
            HttpRequest r = s.getRequest();
            //method
            model.setValueAt(r.getMethod(), s.getId(), 3);
            //host
            String host = r.getHost();
            if(r.getPort()!=80) {
              host +=":"+r.getPort();
            }
            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.jvnet.glassfish.comms.clb.proxy.http.util.HttpRequest

        }

        public boolean invoke(Request request, Response response)
            throws Exception {
           
            HttpRequest httpReq = (HttpRequest) request;               
            String requestUri = httpReq.requestURI().toString();
            if(_logger.isLoggable(Level.FINER))
                _logger.log(Level.FINER,
                        "clb.httpLBM_servicing_request",
                        new Object[]{requestUri});
           
            if (ProxyKeyExtractor.isHttpRequestProxied(httpReq)) {
                if(_logger.isLoggable(Level.FINER))
                    _logger.log(Level.FINER,
                            "clb.httpLBM_request_already_proxied",
                            new Object[]{requestUri});
                setLocalEndPoint(httpReq);

                if(clbMonitoringManager.isCLBMonitoringEnabled()){
                    clbMonitoringManager.getCLBStatsUpdater().
                            incrementTotalIncomingHttpRequestsBE();
                }
                return true;
            }

            if(clbMonitoringManager.isCLBMonitoringEnabled()){
                    clbMonitoringManager.getCLBStatsUpdater().
                            incrementTotalIncomingHttpRequestsFE();
            }
           
            /* Case Controller is null
             * The possibility is that initialization is not done - This may happen in case
             * if converged-load-balancer.xml is corrupt or not present at all
             */
            if (controller == null) {
                /* Only case it can be null is when it is not intialized for load-balancing
                 * Cannot handle this request so setting error in response
                 */
                _logger.log(Level.SEVERE,
                        "clb.controller_null_returning_error",
                        new Object[]{requestUri});
                setErrorInResponse(response);
                return false;
            }

            RequestGroup reqGroup = controller.getRequestGroup(requestUri);
           
            if (reqGroup == null) {
                /* No request group found for this request
                 * let pass it to the same instance and see if it can handle it
                 */
               
                if(_logger.isLoggable(Level.FINER))
                    _logger.log(Level.FINER,
                            "clb.locally_service_request",
                            new Object[]{requestUri});
                setLocalEndPoint(httpReq);
                if(clbMonitoringManager.isCLBMonitoringEnabled()){
                    clbMonitoringManager.getCLBStatsUpdater().
                            incrementTotalLocalHttpRequestsFE();
                    clbMonitoringManager.getCLBStatsUpdater().
                            incrementTotalIncomingHttpRequestsBE();
                }
                return true;
            }

            if(_logger.isLoggable(Level.FINER))
                _logger.log(Level.FINER,
                        "clb.request_group_found",
                        new Object[]{requestUri});
            reqGroup.serviceRequest(httpReq, (Response) response);
           
            if(httpReq.getConvergedLoadBalancerEndpoint() == null){
                _logger.log(Level.SEVERE,
                    "clb.no_endpoint_set_to_service_request",
                    new Object[]{requestUri});
                setErrorInResponse(response);
                return false;
            }

            if (httpReq.getConvergedLoadBalancerEndpoint().isLocal()) {
                if(_logger.isLoggable(Level.FINER))
                    _logger.log(Level.FINER,
                            "clb.request_to_be_serviced_by_local_endpoint",
                            new Object[]{requestUri});
                if(clbMonitoringManager.isCLBMonitoringEnabled()){
    View Full Code Here

    Examples of org.jwall.web.http.HttpRequest

                ByteBuffer buf = super.readBody( header.getContentLength() );
                if( buf == null )
                    return null;
                else {
                    reqNum++;
                    return new HttpRequest( header, buf.array() );
                }
            } else {
                HttpHeader hd = header;
                header = null;
                state = STATE_READING_HEADER;
                reqNum++;
                return new HttpRequest( hd, new byte[0] );
            }
        }
    View Full Code Here

    Examples of org.mockserver.model.HttpRequest

            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")
                                    .withURL("https://localhost:" + SERVER_HTTPS_PORT + "/test_initializer_path")
                                    .withBody("test_initializer_request_body")
                    )
            );
    View Full Code Here

    Examples of org.mortbay.http.HttpRequest

       
        public OutputStreamMessageContext rebase(MessageContext context,
                                                 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);
    View Full Code Here

    Examples of org.mule.transport.http.HttpRequest

    public class ObjectToHttpClientMethodRequestTestCase extends AbstractMuleTestCase
    {
        private MuleMessage setupRequestContext(final String url, final String method) throws Exception
        {
            HttpRequest request = new HttpRequest(new RequestLine(method, url, HttpVersion.HTTP_1_1), null, "UTF-8");

            MuleEvent event = getTestEvent(request, muleContext.getEndpointFactory().getInboundEndpoint(url));
            MuleMessage message = event.getMessage();
            message.setOutboundProperty(HttpConnector.HTTP_METHOD_PROPERTY, method);
            message.setOutboundProperty(MuleProperties.MULE_ENDPOINT_PROPERTY, url);
    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.