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.apache.maven.plugins.site.deploy.SimpleDavServerHandler.HttpRequest

                    String authPass = this.authentications.get( user );
                    if ( password.equals( authPass ) )
                    {
                        String targetPath = request.getServletPath();

                        HttpRequest rq = new HttpRequest();
                        rq.method = request.getMethod();
                        rq.path = targetPath;

                        @SuppressWarnings( "rawtypes" )
                        Enumeration headerNames = request.getHeaderNames();
    View Full Code Here

    Examples of org.apache.mina.http.api.HttpRequest

      public void encode(IoSession session, Object message, ProtocolEncoderOutput out)
          throws Exception {
        LOG.debug("encode {}", message.getClass().getCanonicalName());
        if (message instanceof HttpRequest) {
          LOG.debug("HttpRequest");
          HttpRequest msg = (HttpRequest)message;
          StringBuilder sb = new StringBuilder(msg.getMethod().toString());
          sb.append(" ");
          sb.append(msg.getRequestPath());
          if (!"".equals(msg.getQueryString())) {
            sb.append("?");
            sb.append(msg.getQueryString());
          }
          sb.append(" ");
          sb.append(msg.getProtocolVersion());
          sb.append("\r\n");

          for (Map.Entry<String, String> header : msg.getHeaders().entrySet()) {
                    sb.append(header.getKey());
                    sb.append(": ");
                    sb.append(header.getValue());
                    sb.append("\r\n");
                }
    View Full Code Here

    Examples of org.apache.openejb.server.httpd.HttpRequest

        public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
            if (listener == null) {
                throw new ServletException("RESTServiceContainer has not been set");
            }

            HttpRequest httpRequest = new ServletRequestAdapter(req, res, servletConfig.getServletContext());
            HttpResponse httpResponse = new ServletResponseAdapter(res);

            try {
                listener.onMessage(httpRequest, httpResponse);
            } catch (IOException e) {
    View Full Code Here

    Examples of org.apache.shindig.gadgets.http.HttpRequest

      public void testGetAuthorizationRequest_5() throws Exception {
        final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
        final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
        final String completeAuthorizationUrl = "xxx";

        final HttpRequest result = fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);

        Assert.assertNotNull(result);
        final String postBody = result.getPostBodyAsString();
        Assert.assertNotNull(postBody);
        Assert.assertEquals(
            "client_id=clientId1&client_secret=clientSecret1&grant_type=client_credentials", postBody);
      }
    View Full Code Here

    Examples of org.apache.tomcat.lite.http.HttpRequest

            reqCnt = thr * perthr;
            long t0 = System.currentTimeMillis();

            tr = new ThreadRunner(thr, perthr) {
                public void makeRequest(int i) throws Exception {
                    HttpRequest cstate = clientCon.request("localhost",
                            ssl ? 8443 : 8802);
                    synchronized (active) {
                        active.put(cstate, cstate);
                    }
                    if (spdy) {
                        // Magic way to force spdy - will be replaced with
                        // a negotiation.
                        cstate.setProtocol("SPDY/1.0");
                    }
                    if (ssl) {
                        cstate.setSecure(true);
                    }
                    cstate.requestURI().set("/hello");
                    cstate.setCompletedCallback(reqCallback);
                    // no body
                    cstate.getBody().close();

                    cstate.send();

                    while (active.size() >= thr) {
                        synchronized(thrlock) {
                            thrlock.wait();
                        }
    View Full Code Here

    Examples of org.b3log.latke.urlfetch.HTTPRequest

                final String spec = "http://blogsearch.google.com/ping?name="
                                    + URLEncoder.encode(blogTitle, "UTF-8") + "&url=" + URLEncoder.encode(blogHost, "UTF-8")
                                    + "&changesURL=" + URLEncoder.encode(articlePermalink, "UTF-8");
                LOGGER.log(Level.FINER, "Request Google Blog Search Service API[{0}] while adding an "
                                        + "article[title=" + articleTitle + "]", spec);
                final HTTPRequest request = new HTTPRequest();
                request.setURL(new URL(spec));

                URL_FETCH_SERVICE.fetchAsync(request);
            } catch (final Exception e) {
                LOGGER.log(Level.SEVERE, "Ping Google Blog Search Service fail while adding an article[title=" + articleTitle + "]", e);
            }
    View Full Code Here

    Examples of org.browsermob.proxy.jetty.http.HttpRequest

                throw new UnavailableException("Could not instantiate "+_class);

            // Service the request
            boolean servlet_error=true;
            Principal user=null;
            HttpRequest http_request=null;
            try
            {
                // Handle aliased path
                if (_forcedPath!=null)
                    // TODO complain about poor naming to the Jasper folks
                    request.setAttribute("org.apache.catalina.jsp_file",_forcedPath);

                // Handle run as
                if (_runAs!=null && _realm!=null)
                {
                    http_request=getHttpContext().getHttpConnection().getRequest();
                    user=_realm.pushRole(http_request.getUserPrincipal(),_runAs);
                    http_request.setUserPrincipal(user);
                }
               
                servlet.service(request,response);
                servlet_error=false;
            }
            catch(UnavailableException e)
            {
                if (_servlets!=null && servlet!=null)
                    stop();
                makeUnavailable(e);
            }
            finally
            {
                // pop run-as role
                if (_runAs!=null && _realm!=null && user!=null)
                {
                    user=_realm.popRole(user);
                    http_request.setUserPrincipal(user);
                }

                // Handle error params.
                if (servlet_error)
                    request.setAttribute("javax.servlet.error.servlet_name",getName());
    View Full Code Here

    Examples of org.cruxframework.crux.core.server.rest.spi.HttpRequest

          HttpUtil.sendError(res, HttpServletResponse.SC_BAD_REQUEST, "Failed to parse request.");
          logger.warn("Failed to parse request.", e);
          return;
        }
       
        HttpRequest request = new HttpRequest(req, headers, uriInfo, method);
        HttpResponse response = new HttpResponse(res);

        boolean localeInitializedByServlet = false;
        try
        {
    View Full Code Here

    Examples of org.cspoker.common.api.shared.http.HTTPRequest

        SitInAnywhereAction action1 = new SitInAnywhereAction(eid1,tid,6500);
        queue.add(action1);
        BetOrRaiseAction action2 = new BetOrRaiseAction(eid2,tid,25);
        queue.add(action2);
       
        HTTPRequest request =  new HTTPRequest(queue);
       
        marschaller.marshal(request, output);
       
        HTTPResponse response = new HTTPResponse();
        response.addActionResult(new ActionPerformedEvent<Void>(action1,null));
    View Full Code Here

    Examples of org.cybergarage.http.HTTPRequest

         
        } catch (Exception e) {
          //throw new ParserException(e);
        }

        HTTPRequest httpReq = new HTTPRequest();
        httpReq.setMethod(HTTP.GET);
        httpReq.setURI(uri);
        HTTPResponse httpRes = httpReq.post(host, port);
        if (httpRes.isSuccessful() == false)
          throw new ParserException("HTTP comunication failed: no answer from peer." +
              "Unable to retrive resoure -> "+locationURL.toString());
        String content = new String(httpRes.getContent());
        ByteArrayInputStream strBuf = new ByteArrayInputStream(content.getBytes());
    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.