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 de.netseeker.ejoe.http.HttpRequest

            // shall we act as clientside and initialize the handshake?
            if ( header.isClient() )
            {
                // create a new HTTP HEAD operation and send our client header and the requested adapter (if any)
                hBuffer = new HttpRequest( header, HttpRequest.HTTP_HEAD ).toByteBuffer();
                semiBlockingWrite( channel, hBuffer, timeout );
                // something strange happened - at least the handshake data must be written in one operation
                if ( hBuffer.hasRemaining() ) return null;
            }
    View Full Code Here

    Examples of de.taimos.httputils.HTTPRequest

        try {
          final String body;
          final String due = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
          final String bodyString = "{\"version\":{\"name\":\"%s\",\"status\":\"closed\",\"due_date\":\"%s\"}}";
          body = String.format(bodyString, version.getName(), due);
          final HTTPRequest req = this.createRequest("/versions/" + version.getId() + ".json");
          req.header(WSConstants.HEADER_CONTENT_TYPE, Redmine.APPLICATION_JSON);
          final HttpResponse put = req.body(body).put();
          if (!WS.isStatusOK(put)) {
            this.log.error(WS.getResponseAsString(put));
            throw new RedmineException(Redmine.STATUS_CHANGE_FAILED);
          }
        } catch (final Exception e) {
    View Full Code Here

    Examples of facebook4j.internal.http.HttpRequest

            params[14] = new HttpParameter("pass", p.getProperty("login.password"));
            params[15] = new HttpParameter("persistent", "1");
            params[16] = new HttpParameter("default_persistent", "0");
            params[17] = new HttpParameter("login", "ログイン");

            response = http.request(new HttpRequest(RequestMethod.POST, authorizeURL, params, null, null));

            // dialog
            String dialogURL = response.getResponseHeader("Location").replaceAll("&amp%3B", "&");
            response = http.request(new HttpRequest(RequestMethod.GET, dialogURL, null, null, null));
            if (null != response.getResponseHeader("Location")) {
                String redirectURL = response.getResponseHeader("Location");
                assertThat(redirectURL.contains("code"), is(true));
                return;
            }

            // read
            resStr = response.asString();
            String readURL = "https://www.facebook.com" + catchPattern(resStr, "id=\\\"platformDialogForm\\\" action=\\\"", "\" method=\\\"post\\\"").replaceAll("\\\\", "");
            params = new HttpParameter[18];
            params[0] = new HttpParameter("fb_dtsg", catchPattern(resStr
                        , "name=\\\"fb_dtsg\\\" value=\\\"", "\\\" autocomplete=\\\"off\\\" \\/>"));
            params[1] = new HttpParameter("app_id", oAuthAppId);
            params[2] = new HttpParameter("redirect_uri", callbackURL);
            params[3] = new HttpParameter("display", "page");
            params[4] = new HttpParameter("access_token", "");
            params[5] = new HttpParameter("sdk", "");
            params[6] = new HttpParameter("from_post", "1");
            params[7] = new HttpParameter("public_info_nux", catchPattern(resStr
                        , "name=\\\"public_info_nux\\\" value=\\\"", "\\\" \\/>"));
            params[8] = new HttpParameter("login", catchPattern(resStr
                        , "name=\\\"login\\\" value=\\\"", "\\\" \\/>"));
            params[9] = new HttpParameter("read", catchPattern(resStr
                        , "name=\\\"read\\\" value=\\\"", "\\\" \\/>"));
            params[10] = new HttpParameter("write", catchPattern(resStr
                        , "name=\\\"write\\\" value=\\\"", "\\\" \\/>"));
            params[11] = new HttpParameter("extended", catchPattern(resStr
                        , "name=\\\"extended\\\" value=\\\"", "\\\" \\/>"));
            params[12] = new HttpParameter("confirm", catchPattern(resStr
                        , "name=\\\"confirm\\\" value=\\\"", "\\\" \\/>"));
            params[13] = new HttpParameter("auth_type", "");
            params[14] = new HttpParameter("auth_nonce", "");
            params[15] = new HttpParameter("return_format", catchPattern(resStr
                    , "name=\\\"return_format\\\" value=\\\"", "\\\" \\/>"));
            params[16] = new HttpParameter("domain", "");
            params[17] = new HttpParameter("sso_device", "");

            response = http.request(new HttpRequest(RequestMethod.POST, readURL, params, null, null));

            String redirectURL = response.getResponseHeader("Location");
            assertThat(redirectURL.contains("code"), is(true));
        }
    View Full Code Here

    Examples of freenet.support.api.HTTPRequest

            URI refererURI = new URI(URIPreEncoder.encode(referer));
            String path = refererURI.getPath();
            while(path.startsWith("/")) path = path.substring(1);
            if("".equals(path)) return "/";
            FreenetURI furi = new FreenetURI(path);
            HTTPRequest req = new HTTPRequestImpl(refererURI, "GET");
            String type = req.getParam("type");
            referer = "/" + furi.toString();
            if(type != null && type.length() > 0)
              referer += "?type=" + type;
          } catch (MalformedURLException e) {
            referer = "/";
    View Full Code Here

    Examples of io.fathom.http.HttpRequest

        public ImportImageClient(HttpClient httpClient, URI baseUri) {
            super(httpClient, baseUri);
        }

        public ImageImportMetadata getMetadata(URI uri) throws RestClientException {
            HttpRequest request = getHttpClient().buildRequest(HttpMethod.GET, uri);
            addHeaders(request);

            ImageImportMetadata metadata = doRequest(request, ImageImportMetadata.class);
            return metadata;
        }
    View Full Code Here

    Examples of io.netty.handler.codec.http.HttpRequest

        }

        @Override
        public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
      if (msg instanceof HttpRequest) {
          HttpRequest request = (HttpRequest) msg;
          String uri = request.getUri();
          switch (uri) {
          case "/plaintext":
        writeResponse(ctx, request, CONTENT_BUFFER.duplicate(), TYPE_PLAIN, contentLength);
        return;
          case "/json":
    View Full Code Here

    Examples of io.socket.http.HttpRequest

            emitter.off(callback);
        }

        @Override
        public void handle(HttpContext context) throws IOException {
            HttpRequest req = context.getRequest();
            HttpResponse resp = context.getResponse();

            Iterator<String> parts = Splitter.on('/').omitEmptyStrings().split(Strings.nullToEmpty(req.getPathInfo())).iterator();
            if (!parts.hasNext()) {
                resp.sendError(400, String.format("Protocol version required (supports v%d)", PROTOCOL_VERSION));
                return;
            }
    View Full Code Here

    Examples of jade.imtp.leap.http.HTTPRequest

      NIOJICPConnection connection;
      private static Logger log = Logger.getLogger(NIOHTTPHelper.class.getName());


      public static ByteBuffer readByteBufferFromHttp(InputStream is) throws IOException {
        HTTPRequest request = new HTTPRequest();
        request.readFrom(is);
        if (is.markSupported()) {
          is.mark(2);
          if (is.read() != -1) {
            is.reset();
            throw new IOException("bytes left in stream after constructing HTTPRequest");
          }
        }
        if (request.getMethod().equals("GET")) {
          String recipientID = request.getField(RECIPIENT_ID_FIELD);
          JICPPacket pkt = new JICPPacket(JICPProtocol.CONNECT_MEDIATOR_TYPE, JICPProtocol.DEFAULT_INFO, recipientID, null);
          ByteBuffer b = ByteBuffer.allocateDirect(pkt.getLength());
          MyOut out = new MyOut(b);
          pkt.writeTo(out);
          b.flip();
          return b;
        } else {
          // Read the JICPPacket from the HTTP request payload
          byte[] a = request.getPayload();
          ByteBuffer b = ByteBuffer.allocateDirect(a.length);
          MyOut out = new MyOut(b);
          out.write(a, 0, a.length);
          b.flip();
          return b;
    View Full Code Here

    Examples of javango.http.HttpRequest

      }
     
      public HttpResponse get(String url) throws HttpException {
        String[] urlAndParams = url.split("\\?");
        if (request != null) request.close();
        request = new HttpRequest();
        request.setContext("/");
        request.setUser(user);
        request.setPath(urlAndParams[0]);
        request.setMethod("GET");
        request.setSession(session);
    View Full Code Here

    Examples of kilim.http.HttpRequest

            @Override
            public void execute() throws Pausable, Exception {
                try {
                    // We will reuse the req and resp objects
                    HttpRequest req = new HttpRequest();
                    HttpResponse resp = new HttpResponse();
                    while (true) {
                        super.readRequest(req);
                        System.out.println("Received: " + req);
                        if (req.method.equals("GET") || req.method.equals("HEAD")) {
                            resp.setContentType("text/html");
                            PrintWriter pw = new PrintWriter(resp.getOutputStream());
                            // Note that resp.getOutputStream() does not write to the socket; it merely buffers the entire
                            // output.
                            pw.append("<html><body>path = ");
                            pw.append(req.uriPath).append("<p>");
                            KeyValues kvs = req.getQueryComponents();
                            for (int i = 0; i < kvs.count; i++) {
                                pw.append(kvs.keys[i]).append(" = ").append(kvs.values[i]).append("<br>");
                            }
                            pw.append("</body></html>");
                            pw.flush();
                            sendResponse(resp);
                        } else {
                            super.problem(resp, HttpResponse.ST_FORBIDDEN, "Only GET and HEAD accepted");
                        }
                       
                        if (!req.keepAlive())
                            break;
                        break;
                    }
                } catch (EOFException e) {
                    System.out.println("[" + this.id + "] Connection Terminated");
    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.