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.nutz.socialauth.alipay.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 org.openqa.jetty.http.HttpRequest

        /* ------------------------------------------------------------ */
        public boolean handleNext()
        {
            AJP13RequestPacket packet=null;
            HttpRequest request=getRequest();
            HttpResponse response=getResponse();
            HttpContext context=null;
            boolean gotRequest=false;
            _persistent=true;
            _keepAlive=true;

            try
            {
                try
                {
                    packet=null;
                    packet=_ajpIn.nextPacket();
                    if (packet==null)
                        return false;
                    if (packet.getDataSize()==0)
                        return true;
                }
                catch (IOException e)
                {
                    LogSupport.ignore(log,e);
                    return false;
                }

                int type=packet.getByte();
                if (log.isDebugEnabled())
                    log.debug("AJP13 type="+type+" size="+packet.unconsumedData());

                switch (type)
                {
                    case AJP13Packet.__FORWARD_REQUEST:
                        request.setTimeStamp(System.currentTimeMillis());

                        request.setState(HttpMessage.__MSG_EDITABLE);
                        request.setMethod(packet.getMethod());
                        request.setVersion(packet.getString());
            String version=packet.getString();
            try
            {
          request.setVersion(version);
            }
            catch(Exception e)
            {
          log.warn("Bad version"+version,e);
          log.warn(packet.toString());
            }

                        String path=packet.getString();
                        int sc=path.lastIndexOf(";");
                        if (sc<0)
                            request.setPath(URI.encodePath(path));
                        else
                            request.setPath(URI.encodePath(path.substring(0,sc))+path.substring(sc));

                        _remoteAddr=packet.getString();
                        _remoteHost=packet.getString();
                        _serverName=packet.getString();
                        _serverPort=packet.getInt();
                        _isSSL=packet.getBoolean();

                        // Check keep alive
                        _keepAlive=request.getDotVersion()>=1;

                        // Headers
                        int h=packet.getInt();
                        for (int i=0; i<h; i++)
                        {
                            String hdr=packet.getHeader();
                            String val=packet.getString();
                            request.addField(hdr,val);
                            if (!_keepAlive&&hdr.equalsIgnoreCase(HttpFields.__Connection)&&val.equalsIgnoreCase(HttpFields.__KeepAlive))
                                _keepAlive=true;
                        }

                        // Handler other attributes
                        byte attr=packet.getByte();
                        while ((0xFF&attr)!=0xFF)
                        {
                            String value=(attr==11)?null:packet.getString();
                            switch (attr)
                            {
                                case 11: // key size
                                    request.setAttribute("javax.servlet.request.key_size",new Integer(packet.getInt()));
                                    break;
                                case 10: // request attribute
                                    request.setAttribute(value,packet.getString());
                                    break;
                                case 9: // SSL session
                                    request.setAttribute("javax.servlet.request.ssl_session",value);
                                    break;
                                case 8: // SSL cipher
                                    request.setAttribute("javax.servlet.request.cipher_suite",value);
                                    break;
                                case 7: // SSL cert
                                    // request.setAttribute("javax.servlet.request.X509Certificate",value);
                                    CertificateFactory cf=CertificateFactory.getInstance("X.509");
                                    InputStream certstream=new ByteArrayInputStream(value.getBytes());
                                    X509Certificate cert=(X509Certificate)cf.generateCertificate(certstream);
                                    X509Certificate certs[]=
                                    { cert };
                                    request.setAttribute("javax.servlet.request.X509Certificate",certs);
                                    break;
                                case 6: // JVM Route
                                    request.setAttribute("org.openqa.jetty.http.ajp.JVMRoute",value);
                                    break;
                                case 5: // Query String
                                    request.setQuery(value);
                                    break;
                                case 4: // AuthType
                                    request.setAuthType(value);
                                    break;
                                case 3: // Remote User
                                    request.setAuthUser(value);
                                    break;

                                case 2: // servlet path not implemented
                                case 1: // _context not implemented
                                default:
                                    log.warn("Unknown attr: "+attr+"="+value);
                            }

                            attr=packet.getByte();
                        }

                        _listener.customizeRequest(this,request);

                        gotRequest=true;
                        statsRequestStart();
                        request.setState(HttpMessage.__MSG_RECEIVED);

                        // Complete response
                        if (request.getContentLength()==0&&request.getField(HttpFields.__TransferEncoding)==null)
                            _ajpIn.close();

                        // Prepare response
                        response.setState(HttpMessage.__MSG_EDITABLE);
                        response.setVersion(HttpMessage.__HTTP_1_1);
    View Full Code Here

    Examples of org.openqa.selenium.remote.http.HttpRequest

            throw new SessionNotFoundException(
                "Session ID is null. Using WebDriver after calling quit()?");
          }
        }

        HttpRequest request = commandCodec.encode(command);

        String requestUrl = remoteServer.toExternalForm().replaceAll("/$", "")
            + request.getUri();

        HttpUriRequest httpMethod = createHttpUriRequest(request.getMethod(), requestUrl);
        for (String name : request.getHeaderNames()) {
          // Skip content length as it is implicitly set when the message entity is set below.
          if (!"Content-Length".equalsIgnoreCase(name)) {
            for (String value : request.getHeaders(name)) {
              httpMethod.addHeader(name, value);
            }
          }
        }

        if (httpMethod instanceof HttpPost) {
          ((HttpPost) httpMethod).setEntity(new ByteArrayEntity(request.getContent()));
        }

        try {
          log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), true));
          HttpResponse response = fallBackExecute(context, httpMethod);
    View Full Code Here

    Examples of org.openrdf.http.client.connections.HTTPRequest

      }

      public QueryClient postQuery(QueryLanguage ql, String query, String baseURI)
        throws StoreException, MalformedQueryException
      {
        HTTPRequest request = pool.post();
        try {
          request.sendForm(getQueryParams(ql, query, baseURI));
          execute(request);
          String url = request.readLocation();
          String type = request.readQueryType();
          HTTPConnectionPool location = pool.location(url);
          if (Protocol.GRAPH_QUERY.equals(type)) {
            return new GraphQueryClient(location);
          }
          if (Protocol.BOOLEAN_QUERY.equals(type)) {
            return new BooleanQueryClient(location);
          }
          if (Protocol.BINDINGS_QUERY.equals(type)) {
            return new TupleQueryClient(location);
          }
          throw new StoreException("Unsupported query type: " + type);
        }
        catch (IOException e) {
          throw new StoreException(e);
        }
        finally {
          request.release();
        }
      }
    View Full Code Here

    Examples of org.openrdf.http.client.connections.HTTPRequest

      public TupleResult sendTupleQuery(QueryLanguage ql, String query, Dataset dataset,
          boolean includeInferred, Binding... bindings)
        throws StoreException, MalformedQueryException
      {
        final HTTPRequest request = pool.post();
        request.sendForm(getQueryParams(ql, query, dataset, includeInferred, bindings));
        Callable<TupleResult> task = new Callable<TupleResult>() {

          public TupleResult call()
            throws Exception
          {
            try {
              request.acceptTupleQueryResult();
              execute(request);
              return request.getTupleQueryResult();
            }
            catch (NoCompatibleMediaType e) {
              throw new UnsupportedRDFormatException(e);
            }
          }
    View Full Code Here

    Examples of org.openrdf.http.client.connections.HTTPRequest

      public void sendTupleQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred,
          TupleQueryResultHandler handler, Binding... bindings)
        throws TupleQueryResultHandlerException, StoreException, MalformedQueryException
      {
        HTTPRequest request = pool.post();

        try {
          request.acceptTupleQueryResult();
          request.sendForm(getQueryParams(ql, query, dataset, includeInferred, bindings));
          execute(request);
          request.readTupleQueryResult(handler);
        }
        catch (NoCompatibleMediaType e) {
          throw new UnsupportedRDFormatException(e);
        }
        catch (IOException e) {
          throw new StoreException(e);
        }
        catch (QueryResultParseException e) {
          throw new StoreException(e);
        }
        finally {
          request.release();
        }
      }
    View Full Code Here

    Examples of org.openrdf.http.client.connections.HTTPRequest

      public GraphResult sendGraphQuery(QueryLanguage ql, String query, Dataset dataset,
          boolean includeInferred, Binding... bindings)
        throws StoreException, MalformedQueryException
      {
        final HTTPRequest request = pool.post();
        request.sendForm(getQueryParams(ql, query, dataset, includeInferred, bindings));
        Callable<GraphResult> task = new Callable<GraphResult>() {

          public GraphResult call()
            throws Exception
          {
            try {
              request.acceptGraphQueryResult();
              execute(request);
              return request.getGraphQueryResult();
            }
            catch (NoCompatibleMediaType e) {
              throw new UnsupportedRDFormatException(e);
            }
          }
    View Full Code Here

    Examples of org.openrdf.http.client.connections.HTTPRequest

      public void sendGraphQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred,
          RDFHandler handler, Binding... bindings)
        throws RDFHandlerException, StoreException, MalformedQueryException
      {
        HTTPRequest request = pool.post();

        try {
          request.acceptRDF(false);
          request.sendForm(getQueryParams(ql, query, dataset, includeInferred, bindings));
          execute(request);
          request.readRDF(handler);
        }
        catch (NoCompatibleMediaType e) {
          throw new UnsupportedRDFormatException(e);
        }
        catch (IOException e) {
          throw new StoreException(e);
        }
        catch (RDFParseException e) {
          throw new StoreException(e);
        }
        finally {
          request.release();
        }
      }
    View Full Code Here

    Examples of org.openrdf.http.client.connections.HTTPRequest

      public boolean sendBooleanQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred,
          Binding... bindings)
        throws StoreException, MalformedQueryException
      {
        HTTPRequest request = pool.post();

        try {
          request.acceptBoolean();
          request.sendForm(getQueryParams(ql, query, dataset, includeInferred, bindings));
          execute(request);
          return request.readBoolean();
        }
        catch (NoCompatibleMediaType e) {
          throw new UnsupportedRDFormatException(e);
        }
        catch (IOException e) {
          throw new StoreException(e);
        }
        catch (QueryResultParseException e) {
          throw new StoreException(e);
        }
        finally {
          request.release();
        }
      }
    View Full Code Here

    Examples of org.resteasy.spi.HttpRequest

                        log.debug("final request path: " + path);
                        List<PathSegment> pathSegments = PathSegmentImpl.parseSegments(path);
                        UriInfoImpl uriInfo = new UriInfoImpl(absolutePath, path, request.getQueryString(), pathSegments);

                        HttpRequest in;
                        try
                        {
                            in =
                                new HttpServletInputMessage(
                                    headers,
    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.