Examples of HttpConnection


Examples of org.apache.commons.httpclient.HttpConnection

        {
          //Same details, no need to reset
        }
        else
        {
          httpConn = new HttpConnection(hc);
          //TODO check these
            httpConn.setProxyHost(System.getProperty("http.proxyHost"));
            httpConn.setProxyPort( Integer.parseInt(System.getProperty("http.proxyPort","80")));
        }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

    res.setSampleLabel(urlStr);
    res.sampleStart(); // Count the retries as well in the time

        try
        {
            HttpConnection connection = setupConnection(url, method, res);
             
            if (method.equals(POST))
            {
                sendPostData(httpMethod);
            }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

        subscribeMethod.addRequestHeader(SubscribeMethod.H_DEPTH, ((depth == DepthSupport.DEPTH_INFINITY ) ? "infinity" : String.valueOf(depth)));
        try {
            subscribeMethod.setDoAuthentication(true);
            HttpState httpState = new HttpState();
            httpState.setCredentials(null, repositoryHost, credentials);
            HttpConnection httpConnection = new HttpConnection(repositoryHost, repositoryPort, protocol);
            httpConnection.setConnectionTimeout(CONNECTION_TIMEOUT);
            int state = subscribeMethod.execute(httpState, httpConnection);
            if ( state == HttpStatus.SC_OK ) {
                String subscriptionId = subscribeMethod.getResponseHeader(SubscribeMethod.H_SUBSCRIPTION_ID).getValue();
                logger.log(Level.INFO, "Received subscription id="+subscriptionId+", listener: "+listener);
                int id = Integer.valueOf(subscriptionId).intValue();
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

                    unsubscribeMethod.addRequestHeader(UnsubscribeMethod.H_SUBSCRIPTION_ID, id);
                    try {
                        unsubscribeMethod.setDoAuthentication(true);
                        HttpState httpState = new HttpState();
                        httpState.setCredentials(null, repositoryHost, credentials);
                        HttpConnection httpConnection = new HttpConnection(repositoryHost, repositoryPort, protocol);
                        httpConnection.setConnectionTimeout(CONNECTION_TIMEOUT);
                        int state = unsubscribeMethod.execute(httpState, httpConnection);
                        if ( state == HttpStatus.SC_OK ) {
                            i.remove();
                            return true;
                        } else {
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

    protected void fireEvent(EventMethod eventMethod, Credentials credentials) throws IOException {
        eventMethod.setDoAuthentication(true);
        HttpState httpState = new HttpState();
        httpState.setCredentials(null, repositoryHost, credentials);
        int state = eventMethod.execute(httpState, new HttpConnection(repositoryHost, repositoryPort, protocol));
        if ( state == HttpStatus.SC_OK ) {
        } else {
            logger.log(Level.SEVERE, "Event failed. State: "+state);
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

            pollMethod.addRequestHeader(SubscribeMethod.H_SUBSCRIPTION_ID, pollSubscribers);
            try {
                pollMethod.setDoAuthentication(true);
                HttpState httpState = new HttpState();
                httpState.setCredentials(null, repositoryHost, credentials);
              HttpConnection httpConnection = new HttpConnection(repositoryHost, repositoryPort, protocol);
              httpConnection.setConnectionTimeout(CONNECTION_TIMEOUT);
                int state = pollMethod.execute(httpState, httpConnection);
                if ( state == HttpStatus.SC_MULTI_STATUS ) {
                    List events = pollMethod.getEvents();
                    for ( Iterator i = events.iterator(); i.hasNext(); ) {
                        Event event = (Event)i.next();
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

        {
          //Same details, no need to reset
        }
        else
        {
          httpConn = new HttpConnection(hc);
          //TODO check these
            httpConn.setProxyHost(System.getProperty("http.proxyHost"));
            httpConn.setProxyPort( Integer.parseInt(System.getProperty("http.proxyPort","80")));
        }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

    res.setSampleLabel(urlStr);
    res.sampleStart(); // Count the retries as well in the time

        try
        {
            HttpConnection connection = setupConnection(url, method, res);
             
            if (method.equals(POST))
            {
                sendPostData(httpMethod);
            }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

        }
       
        Iterator connectionIter = connectionToAdded.keySet().iterator();
       
        while (connectionIter.hasNext()) {
            HttpConnection conn = (HttpConnection) connectionIter.next();
            Long connectionTime = (Long) connectionToAdded.get(conn);
            if (connectionTime.longValue() <= idleTimeout) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Closing connection, connection time: "  + connectionTime);
                }
                connectionIter.remove();
                conn.close();
            }
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpConnection

  }

  public XScriptObject invoke()
    throws ProcessingException
  {
    HttpConnection conn = null;

    try {
      if (action == null || action.equals(""))
        action = "\"\"";

      String host = url.getHost();
      int port = url.getPort();

      if (System.getProperty("http.proxyHost") != null) {
        String proxyHost = System.getProperty("http.proxyHost");
        int proxyPort = Integer.parseInt(System.getProperty("http.proxyPort"));
        conn = new HttpConnection(proxyHost, proxyPort, host, port);
      }
      else {
        conn = new HttpConnection(host, port);
      }

      PostMethod method = new PostMethod(url.getFile()) {
          protected String generateRequestBody(HashMap params)
          {
            try {
              StringBuffer bodyBuffer
                = new StringBuffer(super.generateRequestBody(params));

              // Write the SOAP request
              InputSource saxInputStream = xscriptObject.getInputSource();
              InputStream is = saxInputStream.getByteStream();
              InputStreamReader isr = new InputStreamReader(is);

              char[] buffer = new char[1024];
              int len;
              while ((len = isr.read(buffer)) > 0)
                bodyBuffer.append(buffer, 0, len);
              isr.close();
              is.close();
              return bodyBuffer.toString();
            }
            catch (Exception ex) {
              return null;
            }
          }
        };

        method.setRequestHeader(
                new Header("Content-type", "text/xml; charset=\"utf-8\""));
        method.setRequestHeader(new Header("SOAPAction", action));
        method.setUseDisk(false);

        method.execute(new HttpState(), conn);

        String ret = method.getResponseBodyAsString();
        int startOfXML = ret.indexOf("<?xml");
        if(startOfXML == -1) { // No xml?!
            throw new ProcessingException("Invalid response - no xml");
        }

        return new XScriptObjectInlineXML(
            xscriptManager,
            ret.substring(startOfXML));
    }
    catch (Exception ex) {
      throw new ProcessingException("Error invoking remote service: " + ex,
                                    ex);
    }
    finally {
      try {
        if (conn != null)
          conn.close();
      }
      catch (Exception ex) {
      }
    }
  }
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.