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.google.gwt.gears.client.httprequest.HttpRequest

          }
        });

        upload.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {
            HttpRequest request = factory.createHttpRequest();
            request.open("POST", GWT.getModuleBaseURL() + "upload");
            request.setRequestHeader("X-Filename", selected.getText());

            request.setCallback(new RequestCallback() {
              public void onResponseReceived(HttpRequest request) {
                String msg = request.getStatus() + " " + request.getResponseText();
                if (request.getStatus() != 200) {
                  result.setHTML("<p style=\"color:red\">" + msg + "</p>");
                } else {
                  result.setHTML("<p style=\"color:green\">" + msg + "</p>");
                }
              }
            });

            request.getUpload().setProgressHandler(new ProgressHandler() {
              public void onProgress(ProgressEvent event) {
                double pcnt = ((double) event.getLoaded() / event.getTotal());
                progressInner.setWidth((int) Math.floor(pcnt * 100) + "%");
              }
            });
            request.send(selectedFile);
          }
        });

        HorizontalPanel inputPanel = new HorizontalPanel();
        inputPanel.add(selected);
    View Full Code Here

    Examples of com.knowgate.dfs.HttpRequest

        sUsrPwd = sUserPassword;
      }

      public void run() {
        FileSystem oFs = new FileSystem();
        HttpRequest oReq;
       
        try {
          AtrilSession oSes = DAO.getAdminSession("AsyncAccountCache");
          User oUsr = new User(oSes, User.forUuid(sUsrNick));
          oSes.disconnect();
          oSes.close();

          oReq = new HttpRequest(sBaseUrl+"login.jsp", null, "post",
                       new NameValuePair[]{new NameValuePair("email", oUsr.getEmail()),
                                       new NameValuePair("passw", sUsrPwd),
                                       new NameValuePair("format", "session")});
          oReq.post();
          ArrayList<NameValuePair> aCookies = oReq.getCookies();

          NameValuePair[] aCachedPages = new NameValuePair[] {
            new NameValuePair("acctaxpayers", "ListTaxPayers.action"),
            new NameValuePair("accsuppliers", "ListClients.action"),
            new NameValuePair("accusers", "ListUsers.action")
          };
         
          for (int p=0; p<aCachedPages.length; p++) {
            oReq = new HttpRequest(sBaseUrl+aCachedPages[p].getValue());
            oReq.setCookies(aCookies);
            oReq.get();
            String sDyna = oReq.src();

            oReq = new HttpRequest(sBaseUrl+"cacheread.jsp?key="+sAccId+aCachedPages[p].getName());
            oReq.setCookies(aCookies);
            oReq.get();     
            String sCach = oReq.src();
           
            if (!sDyna.equals(sCach)) {
              oReq = new HttpRequest(sBaseUrl+"cachestore.jsp", null, "post",
              new NameValuePair[]{new NameValuePair("key", sAccId+aCachedPages[p].getName()), new NameValuePair("val", sDyna)});
              oReq.setCookies(aCookies);
              oReq.start();
            }   
          } // next

        } catch (Exception xcpt) {
          Log.out.error("AsyncAccountCache.run() "+xcpt.getClass().getName()+" "+xcpt.getMessage());
    View Full Code Here

    Examples of com.lgx8.common.payment.util.httpClient.HttpRequest

            //待请求参数数组
            Map<String, String> sPara = buildRequestPara(sParaTemp);

            HttpProtocolHandler httpProtocolHandler = HttpProtocolHandler.getInstance();

            HttpRequest request = new HttpRequest(HttpResultType.BYTES);
            //设置编码集
            request.setCharset(AlipayConfig.input_charset);

            request.setParameters(generatNameValuePair(sPara));
            request.setUrl(gateway+"_input_charset="+AlipayConfig.input_charset);

            HttpResponse response = httpProtocolHandler.execute(request);
            if (response == null) {
                return null;
            }
    View Full Code Here

    Examples of com.netflix.client.http.HttpRequest

                for (String value : values) {
                    builder.queryParams(name, value);
                }
            }

            HttpRequest httpClientRequest = builder.build();

            HttpResponse response = restClient.executeWithLoadBalancer(httpClientRequest);
            context.set("ribbonResponse", response);
            return response;
        }
    View Full Code Here

    Examples of com.nimbusds.oauth2.sdk.http.HTTPRequest

        } catch (MalformedURLException e) {

          throw new SerializeException(e.getMessage(), e);
        }

        HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, url);
        httpRequest.setContentType(CommonContentTypes.APPLICATION_URLENCODED);

        if (getClientAuthentication() != null) {
          getClientAuthentication().applyTo(httpRequest);
        }

        Map<String,String> params = httpRequest.getQueryParameters();

        params.putAll(authzGrant.toParameters());

        if (scope != null && ! scope.isEmpty()) {
          params.put("scope", scope.toString());
        }

        if (clientID != null) {
          params.put("client_id", clientID.getValue());
        }

        httpRequest.setQuery(URLUtils.serializeParameters(params));

        return httpRequest;
      }
    View Full Code Here

    Examples of com.noelios.restlet.http.HttpRequest

                Context.setCurrent(getContext());

                // Convert the Servlet call to a Restlet call
                final ServletCall servletCall = new ServletCall(request
                        .getLocalAddr(), request.getLocalPort(), request, response);
                final HttpRequest httpRequest = toRequest(servletCall);
                final HttpResponse httpResponse = new HttpResponse(servletCall,
                        httpRequest);

                // Adjust the relative reference
                httpRequest.getResourceRef().setBaseRef(getBaseRef(request));

                // Adjust the root reference
                httpRequest.setRootRef(getRootRef(request));

                // Handle the request and commit the response
                getTarget().handle(httpRequest, httpResponse);
                commit(httpResponse);
            } else {
    View Full Code Here

    Examples of com.sk89q.skmcl.util.HttpRequest

        }

        private void authenticate() throws IOException, InterruptedException, AuthenticationException {
            Object payload = new AuthenticatePayload(id, password);

            HttpRequest request = HttpRequest
                    .post(AUTH_URL)
                    .bodyJson(payload)
                    .execute();

            if (request.getResponseCode() != 200) {
                ErrorResponse error = request.returnContent().asJson(ErrorResponse.class);
                throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
            } else {
                AuthenticateResponse response =
                        request.returnContent().asJson(AuthenticateResponse.class);
                accessToken = response.getAccessToken();
                clientToken = response.getClientToken();
                identities = response.getAvailableProfiles();
                for (Identity identity : identities) {
                    identity.setAccessToken(accessToken);
    View Full Code Here

    Examples of com.skcraft.launcher.util.HttpRequest

        @Override
        public List<? extends Session> login(String agent, String id, String password)
                throws IOException, InterruptedException, AuthenticationException {
            Object payload = new AuthenticatePayload(new Agent(agent), id, password);

            HttpRequest request = HttpRequest
                    .post(authUrl)
                    .bodyJson(payload)
                    .execute();

            if (request.getResponseCode() != 200) {
                ErrorResponse error = request.returnContent().asJson(ErrorResponse.class);
                throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
            } else {
                AuthenticateResponse response = request.returnContent().asJson(AuthenticateResponse.class);
                return response.getAvailableProfiles();
            }
        }
    View Full Code Here

    Examples of com.xmlcalabash.library.HttpRequest

                }
                tree.startContent();
                tree.addEndElement();
            } else {
                // Let's try HTTP
                HttpRequest httpReq = new HttpRequest(runtime, step);
                Pipe inputPipe = new Pipe(runtime);
                Pipe outputPipe = new Pipe(runtime);
                httpReq.setInput("source", inputPipe);
                httpReq.setOutput("result", outputPipe);

                TreeWriter req = new TreeWriter(runtime);
                req.startDocument(step.getNode().getBaseURI());
                req.addStartElement(XProcConstants.c_request);
                req.addAttribute(_method, "HEAD");
                req.addAttribute(_href, uri.toASCIIString());
                req.addAttribute(_status_only, "true");
                req.addAttribute(_detailed, "true");

                for (QName name : new QName[] {_username, _password, _auth_method, _send_authorization } ) {
                    RuntimeValue v = getOption(name);
                    if (v != null) { req.addAttribute(name, v.getString()); }
                }
               
                req.startContent();
                req.addEndElement();
                req.endDocument();

                inputPipe.write(req.getResult());

                httpReq.run();

                XdmNode result = S9apiUtils.getDocumentElement(outputPipe.read());
                int status = Integer.parseInt(result.getAttributeValue(_status));
               
                tree.addAttribute(_href, href.getString());
    View Full Code Here

    Examples of de.ioexception.www.http.HttpRequest

      @Override
      public Void call() throws Exception
      {
        // Parse request from InputStream
        HttpRequest request = parseRequest(socket.getInputStream());

        // Create appropriate response
        HttpResponse response = handleRequest(request);

        // Send response and close connection, if necessary
    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.