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.dbwiki.web.request.HttpRequest

       * @throws org.dbwiki.exception.WikiException
       */
      protected void respondTo(Exchange<?> exchange) throws java.io.IOException, org.dbwiki.exception.WikiException {
        ServerResponseHandler responseHandler = null;
       
        HttpRequest request = new HttpRequest(new RequestURL(exchange,""), users());

        if (request.type().isIndex()) {
          responseHandler = this.getHomepageResponseHandler(request);
        } else if (request.type().isCreate()) {
          responseHandler = new ServerResponseHandler(request, _wikiTitle + " - Create Database Wiki");
          responseHandler.put(HtmlContentGenerator.ContentContent, new DatabaseWikiFormPrinter("Create Database Wiki"));
        } else if (request.type().isEdit()) {
          DatabaseWiki wiki = this.getRequestWiki(request, RequestParameter.ParameterEdit);
          responseHandler = new ServerResponseHandler(request, _wikiTitle + " - Edit Database Wiki");
          responseHandler.put(HtmlContentGenerator.ContentContent, new DatabaseWikiFormPrinter(wiki.getProperties(), RequestParameterAction.ActionUpdate, "Edit Database Wiki"));
        } else if (request.type().isReset()) {
          this.resetWikiConfiguration(this.getRequestWiki(request, RequestParameter.ParameterReset));
          responseHandler = this.getHomepageResponseHandler(request);
        } else if (request.type().isAction()) {
          RequestParameterAction action = RequestParameter.actionParameter(request.parameters().get(RequestParameter.ParameterAction));
          if (action.actionInsert()) {
            responseHandler = this.getInsertWikiResponseHandler(request);
          } else if (action.actionCancel()) {
            responseHandler = this.getHomepageResponseHandler(request);
          } else if (action.actionUpdate()) {
            responseHandler = this.getUpdateWikiResponseHandler(request);
          } else {
            throw new WikiRequestException(WikiRequestException.InvalidRequest, request.toString());
          }
        } else {
          throw new WikiRequestException(WikiRequestException.InvalidRequest, request.toString());
        }
       
        File template = null;

        //
    View Full Code Here

    Examples of org.deftserver.web.http.HttpRequest

       
       
        String requestLine = "GET / HTTP/1.1";
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("host", "localhost");
        HttpRequest request = new HttpRequest(requestLine, headers);
       
       
        assertNotNull(app.getHandler(request));
       
        requestLine = "GET /persons/1911 HTTP/1.1";
        request = new HttpRequest(requestLine, headers);
        assertNotNull(app.getHandler(request));
       
       
        requestLine = "GET /persons/phone_numbers HTTP/1.1";
        request = new HttpRequest(requestLine, headers);
        assertNotNull(app.getHandler(request));
       
        requestLine = "GET /pets/123 HTTP/1.1";
        request = new HttpRequest(requestLine, headers);
        assertNotNull(app.getHandler(request));
       
       
        request = new HttpRequest("GET /missing HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /persons HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /persons/roger HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /persons/123a HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /persons/a123 HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /pets/a123 HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /pets/123a HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET /pets/1234 HTTP/1.1", headers);
        assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
       
        request = new HttpRequest("GET / HTTP/1.1", headers);
        assertEquals(handler1, app.getHandler(request));
       
        request = new HttpRequest("GET /persons/1911 HTTP/1.1", headers);
        assertEquals(handler2, app.getHandler(request));
       
        request = new HttpRequest("GET /persons/phone_numbers HTTP/1.1", headers);
        assertEquals(handler3, app.getHandler(request));
       
        request = new HttpRequest("GET /pets/123 HTTP/1.1", headers);
        assertEquals(handler4, app.getHandler(request));
       
        //Verify that BadRequestRequestHandler is returned if request does not include Host header
        headers = new HashMap<String, String>();
        request = new HttpRequest("GET /pets/123 HTTP/1.1", headers);
        assertEquals(BadRequestRequestHandler.getInstance(), app.getHandler(request));
       
      }
    View Full Code Here

    Examples of org.eclipse.ecf.internal.provider.rss.http.HttpRequest

      public synchronized boolean isOnTheAir() {
        return isOnTheAir;
      }

      public void handleAccept(Socket socket) throws Exception {
        final HttpRequest request = new HttpRequest(socket.getInputStream());
        final RssServerSOContainer con = (RssServerSOContainer) get(String.valueOf(port));
        if (con == null) {
          throw new IOException("Container for port " + port + " not found!");
        }
        trace("Found container: " + con.getID().getName() + " for target " + request.getURLString());
        String body = "";
        int code = HttpResponse.SERVER_ERROR;
        String path = request.getPath();
        // Tests whether this abstract pathname is absolute.
        path = path.startsWith("/") ? path.substring(1) : path;
        final File feedFile = new File(path);
        Date lastModified = new Date();
        if (feedFile.exists() && feedFile.isFile()) {
    View Full Code Here

    Examples of org.eclipse.jetty.client.HttpRequest

            // apply filters
            request = applyRequestFilters(request);

            // create jetty request and response listener
            HttpRequest jettyRequest = buildJettyRequest(request);
            InputStreamResponseListener listener = new InputStreamResponseListener(maxContentLength)
            {
                @Override
                public void onContent(Response response, ByteBuffer content)
                {
                    // ignore empty blocks
                    if (content.remaining() == 0) {
                        return;
                    }
                    super.onContent(response, content);
                }
            };

            // fire the request
            jettyRequest.send(listener);

            // wait for response to begin
            Response response;
            try {
                response = listener.get(httpClient.getIdleTimeout(), TimeUnit.MILLISECONDS);
    View Full Code Here

    Examples of org.elasticsearch.common.netty.handler.codec.http.HttpRequest

        public HttpRequestHandler(NettyHttpServerTransport serverTransport) {
            this.serverTransport = serverTransport;
        }

        @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
            HttpRequest request = (HttpRequest) e.getMessage();
            serverTransport.dispatchRequest(new NettyHttpRequest(request), new NettyHttpChannel(serverTransport, e.getChannel(), request));
            super.messageReceived(ctx, e);
        }
    View Full Code Here

    Examples of org.expath.httpclient.HttpRequest

            return sendRequest(request, href, bodies);
        }
       
        private Sequence sendRequest(final NodeValue request, final String href, final Sequence bodies) throws XPathException {
           
            HttpRequest req = null;
            try {
                final org.expath.httpclient.model.Sequence b = new EXistSequence(bodies, getContext());
                final Element r = new EXistElement(request, getContext());
                final RequestParser parser = new RequestParser();
                req = parser.parse(r, b, href);

                // override anyway it href exists
                if (href != null && ! "".equals(href) ) {
                    req.setHref(href);
                }
           
                final URI uri = new URI(req.getHref());
                final EXistResult result = sendOnce(uri, req, parser);
                return result.getResult();
                   
            } catch(final URISyntaxException ex ) {
                throw new XPathException("Href is not valid: " + req != null ? req.getHref() : "" + ". " + ex.getMessage(), ex);
            } catch(final HttpClientException hce) {
                throw new XPathException(hce.getMessage(), hce);
            }
        }
    View Full Code Here

    Examples of org.exquery.http.HttpRequest

            super(context, signature);
        }

        @Override
        public final Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException {
            final HttpRequest request = (HttpRequest)getContext().getAttribute(RequestModule.EXQ_REQUEST_ATTR);
            if(request == null) {
                throw new XPathException(this, "The HTTP Request is not defined in the Dynamic Context");
            }
           
            return eval(args, request);
    View Full Code Here

    Examples of org.fto.jthink.j2ee.web.HttpRequest

        /* 设置资源容器, HttpSession用户会话 */
        HttpSession session = new HttpSession(((HttpServletRequest)req).getSession());
        setResourceContainer(HttpSession.class.getName(), session);
       
        /* 设置资源容器, HttpRequest请求 */
        HttpRequest request = new HttpRequest(req);
        setResourceContainer(HttpRequest.class.getName(), request);
       
        /* 设置资源, WEBApplicationContext */
        setResource(WEBApplicationContext.class.getName(), webContext);
       
    View Full Code Here

    Examples of org.ice.http.HttpRequest

        try {
          request.setCharacterEncoding("UTF-8");
        } catch(Exception ex) {
          LogUtils.log(Level.WARNING, "Cannot set character encoding to UTF-8");
        }
        HttpRequest httpRequest = requestParser.parseRequest(new HttpRequest(request));
        HttpResponse httpResponse = new HttpResponse(response);
       
        Exception exception = null;
        try {
          boolean found = false;
          for(IRouter router: routers)  {
            IModule module = router.route(httpRequest);
            if (module != null)  {
              found = true;
              exception = dispatchModule(module, httpRequest, httpResponse, httpRequest.getTaskName());
              break;
            }
          }
          if (!found)
            throw new NotFoundException("No routers match for request: "+request.getRequestURL().toString());
    View Full Code Here

    Examples of org.jboss.arquillian.warp.client.filter.http.HttpRequest

        @Inject
        private Event<DeenrichHttpResponse> deenrichHttpResponse;

        public void tryEnrichRequest(@Observes FilterHttpRequest event) {
            final HttpRequest request = event.getRequest();
            final HttpRequestEnrichmentService enrichmentService = load(HttpRequestEnrichmentService.class);

            if (WarpCommons.debugMode()) {
                System.out.println("        (R) " + request.getUri());
            }

            Collection<RequestPayload> matchingPayloads = enrichmentService.getMatchingPayloads(request);

            if (matchingPayloads.isEmpty()) {
                warpContext().addUnmatchedRequest(request);
            } else {
                if (matchingPayloads.size() > 1) {
                    warpContext().pushException(new MultipleGroupsPerRequestException(request.getUri()));
                } else {
                    enrichHttpRequest.fire(new EnrichHttpRequest(request, matchingPayloads.iterator().next(), enrichmentService));
                }
            }
        }
    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.