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 com.davfx.ninio.http.HttpRequest

            }
           
            if (post != null) {
              method = HttpRequest.Method.POST;
            }
            HttpRequest request = new HttpRequest(a, secure, method, path);
            if (post != null) {
              request.getHeaders().put(Http.CONTENT_LENGTH, String.valueOf(post.remaining()));
            }
            onClient.send(request, new HttpClientHandler() {
              private HttpResponse response = null;
              private InMemoryPost body = null;
             
    View Full Code Here

    Examples of com.ds.http.message.HttpRequest

        }

        public void process() {
            while (!Thread.interrupted() && connection.isOpen()) {
                try {
                    HttpRequest httpRequest = parseConnection();

                    System.out.println("New request received." + httpRequest.getMethod() + " " + httpRequest.getURI() + " " + httpRequest.getHttpVersion());

                    HttpResponse httpResponse = HttpResponseFactory.createHttpResponse(httpRequest, resourceFinder);

                    sendResponse(httpResponse);
    View Full Code Here

    Examples of com.eclipsesource.tabris.tracking.internal.analytics.request.HttpRequest

      public void track( Hit hit, String clientId, AdvancedConfiguration advancedConfiguration ) {
        validateArguments( hit, clientId, advancedConfiguration );
        AnalyticsRequest requestAssembler = new AnalyticsRequest( appName, clientId, configuration, hit, advancedConfiguration );
        Map<String, Object> request = requestAssembler.assemble();
        HttpRequest httpRequest = HttpRequest.get( baseUrl, request, true );
        verifyResponse( httpRequest );
      }
    View Full Code Here

    Examples of com.facebook.presto.jdbc.internal.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 com.facebook.presto.jdbc.internal.netty.handler.codec.http.HttpRequest

            MessageEvent e = (MessageEvent) evt;
            Object msg = e.getMessage();

            if (msg instanceof HttpRequest) {

                HttpRequest httpRequest = (HttpRequest) msg;
                SpdySynStreamFrame spdySynStreamFrame = createSynStreamFrame(httpRequest);
                currentStreamId = spdySynStreamFrame.getStreamId();
                ChannelFuture future = getMessageFuture(ctx, e, currentStreamId, httpRequest);
                Channels.write(ctx, future, spdySynStreamFrame, e.getRemoteAddress());
    View Full Code Here

    Examples of com.github.dreamhead.moco.HttpRequest

        public void writeToResponse(final SessionContext context) {
            Request request = context.getRequest();
            Response response = context.getResponse();

            if (HttpRequest.class.isInstance(request) && MutableHttpResponse.class.isInstance(response)) {
                HttpRequest httpRequest = HttpRequest.class.cast(request);
                MutableHttpResponse httpResponse = MutableHttpResponse.class.cast(response);
                doWriteToResponse(httpRequest, httpResponse);
            }
        }
    View Full Code Here

    Examples of com.github.kevinsawicki.http.HttpRequest

        mPassword = pPassword;
        return this;
      }

      protected HttpRequest createRequest(BankRequest pBankRequest, String pMethod) {
        HttpRequest vHttpRequest = null;
        if (HttpRequest.METHOD_POST.equals(pMethod)) {
          vHttpRequest = new HttpRequest(pBankRequest.getUri(), pMethod);
        } else {
          vHttpRequest = new HttpRequest(pBankRequest.generateUri(), pMethod);
        }
        vHttpRequest.userAgent(USER_AGENT);
        modifyRequest(pBankRequest);
        for (Entry<String, String> header : pBankRequest.getHeaders().entrySet()) {
          vHttpRequest.header(header.getKey(), header.getValue());
        }
        return vHttpRequest;
      }
    View Full Code Here

    Examples of com.github.kristofa.test.http.HttpRequest

        }

        @Test
        public void testReadValidRequestNoEntity() {

            final HttpRequest request =
                reader.read(new File(TEST_FILE_DIRECTORY, "HttpRequestFileReaderTest_valid_file.txt"), new File(
                    "unexisting_file.txt"));
            assertEquals(Method.POST, request.getMethod());
            assertEquals("/a/b", request.getPath());
            final Set<HttpMessageHeader> httpMessageHeaders = request.getHttpMessageHeaders();
            assertEquals(2, httpMessageHeaders.size());
            assertTrue(httpMessageHeaders.contains(new HttpMessageHeader("Content-Type", "application/json; charset=UTF-8")));
            assertTrue(httpMessageHeaders.contains(new HttpMessageHeader("Agent", "Eclipse")));
            final Set<QueryParameter> queryParameters = request.getQueryParameters();
            assertEquals(3, queryParameters.size());
            assertTrue(queryParameters.contains(new QueryParameter("a", "b")));
            assertTrue(queryParameters.contains(new QueryParameter("a", "c")));
            assertTrue(queryParameters.contains(new QueryParameter("c", "d")));
            assertNull(request.getContent());
        }
    View Full Code Here

    Examples of com.google.api.client.http.HttpRequest

      public <T extends IDoubanObject> T getResponse(String url, List<NameValuePair> params, Class<T> responseType, boolean needAccessToken) throws DoubanException, IOException {
        if (params != null && params.size() > 0) {
          String encodedParams = encodeParameters(params);
          url = url + "?" + encodedParams;
        }
        HttpRequest method = requestFactory.buildGetRequest(new GenericUrl(url));
        return httpRequest(method, needAccessToken).parseAs(responseType);
      }
    View Full Code Here

    Examples of com.google.appengine.api.urlfetch.HTTPRequest

        String currentUrl = url;

        for (int i = 0; i <= requestOptions.getMaxRedirects(); i++) {

          HTTPRequest httpRequest = new HTTPRequest(new URL(currentUrl),
              method, options);

          addHeaders(httpRequest, requestOptions);

          if (method == HTTPMethod.POST && content != null) {
            httpRequest.setPayload(content.getBytes());
          }

          HTTPResponse httpResponse;
          try {
            httpResponse = fetchService.fetch(httpRequest);
    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.