You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Akinori ITO <ak...@paso.fujitsu.co.jp> on 2000/11/14 05:37:13 UTC

HTTP proxy patch

Hi all.

I made a HTTP proxy patch which can connect to the SOAP server
via the HTTP proxy.

Most HTTP browsers support the HTTP access via the proxy server. 
Apache SOAP 2.0 did not support the HTTP proxy server
though using the HTTP communication. 

Please call the following before invoking the Call object. 

Example:

 HTTPUtils.SetProxy("proxy", 10080); // set static variables

Thanks
--
ITO Akinori
akito@paso.fujitsu.co.jp

xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java 1.7
*** /tmp/T05WaOoH       Tue Nov 14 11:15:16 2000
--- HTTPUtils.java      Tue Nov 14 11:14:34 2000
***************
*** 74,79 ****
--- 74,81 ----
    private static final String HEADER_CONTENT_TYPE = "Content-Type";
    private static final String HEADER_CONTENT_LENGTH = "Content-Length";
    private static final int    HTTP_DEFAULT_PORT = 80;
+   private static String HTTP_PROXY_HOST = null;
+   private static int    HTTP_PROXY_PORT = 80;

    /**
     * An instance of this class is returned by post.
***************
*** 119,125 ****
        if (port < 0)  // No port given..use HTTP default which is pry 80 :-)
          port = HTTP_DEFAULT_PORT;

!       Socket s = new Socket (url.getHost (), port);
        s.setSoTimeout(timeout);
        out = new PrintWriter (s.getOutputStream ());
        in = new BufferedReader (new InputStreamReader (s.getInputStream ()));
--- 121,132 ----
        if (port < 0)  // No port given..use HTTP default which is pry 80 :-)
          port = HTTP_DEFAULT_PORT;

!       Socket s;
!       if (HTTP_PROXY_HOST == null) {
!         s = new Socket (url.getHost (), port);
!       } else {
!         s = new Socket (HTTP_PROXY_HOST, HTTP_PROXY_PORT);
!       }
        s.setSoTimeout(timeout);
        out = new PrintWriter (s.getOutputStream ());
        in = new BufferedReader (new InputStreamReader (s.getInputStream ()));
***************
*** 129,136 ****
      }

      /* send it out */
!     out.print (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION +
!                "\r\n");
      out.print (HEADER_HOST + ": " + url.getHost () + ':' + port + "\r\n");
      out.print (HEADER_CONTENT_TYPE + ": " + contentType + "\r\n");
      out.print (HEADER_CONTENT_LENGTH + ": " + content.length () + "\r\n");
--- 136,148 ----
      }

      /* send it out */
!     if (HTTP_PROXY_HOST == null) {
!       out.print (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION +
!                  "\r\n");
!     } else {
!       out.print (HTTP_POST + " " + url.toString() + " HTTP/" + HTTP_VERSION +
!                  "\r\n");
!     }
      out.print (HEADER_HOST + ": " + url.getHost () + ':' + port + "\r\n");
      out.print (HEADER_CONTENT_TYPE + ": " + contentType + "\r\n");
      out.print (HEADER_CONTENT_LENGTH + ": " + content.length () + "\r\n");
***************
*** 195,198 ****
--- 207,221 ----
      return new Response (statusCode, statusString, respHeaders,
                           respContentLength, respContentType, in);
    }
+
+   /**
+    * Set HTTP proxy.
+    *
+    * @param host the HTTP proxy host or null if no proxy.
+    * @param port the HTTP proxy port
+    */
+   public static void SetProxy(String host, int port) {
+     HTTP_PROXY_HOST = host;
+     HTTP_PROXY_PORT = port;
+   }
  }

Re: HTTP proxy patch

Posted by Ryo Neyama <ne...@trl.ibm.co.jp>.
Sanjiva,

I have one question.

I don't know why we don't use java.net.URLConnection instead of
HTTPUtils.  Is it for the customize-ability reason?  Or something
else?

I'm sorry but I've not checked all mails posted to this mailing list
yet, and I don't know what's the reason for the decision...

Regards,
    Ryo Neyama @ IBM Research, Tokyo Research Laboratory
    Internet Technology
    neyama@trl.ibm.co.jp

> > Hi all.
> >
> > I made a HTTP proxy patch which can connect to the SOAP server
> > via the HTTP proxy.
> >
> > Most HTTP browsers support the HTTP access via the proxy server.
> > Apache SOAP 2.0 did not support the HTTP proxy server
> > though using the HTTP communication.
> >
> > Please call the following before invoking the Call object.
> >
> > Example:
> >
> >  HTTPUtils.SetProxy("proxy", 10080); // set static variables
> >
> > Thanks
> > --
> > ITO Akinori
> > akito@paso.fujitsu.co.jp

> Thanks for sending this - I committed it with a minor change: method
> name changed to setProxy instead of SetProxy. Hope that's ok!
>
> When we do get around to updating the docs this needs to be described
> as this is a very useful piece of functionality for many people.
>
> Sanjiva.

Re: HTTP proxy patch

Posted by Ryo Neyama <ne...@trl.ibm.co.jp>.
Sanjiva,

I have one question.

I don't know why we don't use java.net.URLConnection instead of
HTTPUtils.  Is it for the customize-ability reason?  Or something
else?

I'm sorry but I've not checked all mails posted to this mailing list
yet, and I don't know what's the reason for the decision...

Regards,
    Ryo Neyama @ IBM Research, Tokyo Research Laboratory
    Internet Technology
    neyama@trl.ibm.co.jp

> > Hi all.
> >
> > I made a HTTP proxy patch which can connect to the SOAP server
> > via the HTTP proxy.
> >
> > Most HTTP browsers support the HTTP access via the proxy server.
> > Apache SOAP 2.0 did not support the HTTP proxy server
> > though using the HTTP communication.
> >
> > Please call the following before invoking the Call object.
> >
> > Example:
> >
> >  HTTPUtils.SetProxy("proxy", 10080); // set static variables
> >
> > Thanks
> > --
> > ITO Akinori
> > akito@paso.fujitsu.co.jp

> Thanks for sending this - I committed it with a minor change: method
> name changed to setProxy instead of SetProxy. Hope that's ok!
>
> When we do get around to updating the docs this needs to be described
> as this is a very useful piece of functionality for many people.
>
> Sanjiva.

Re: HTTP proxy patch

Posted by Sanjiva Weerawarana <sa...@watson.ibm.com>.
Thanks for sending this - I committed it with a minor change: method
name changed to setProxy instead of SetProxy. Hope that's ok!

When we do get around to updating the docs this needs to be described
as this is a very useful piece of functionality for many people.

Sanjiva.

----- Original Message -----
From: "Akinori ITO" <ak...@paso.fujitsu.co.jp>
To: <so...@xml.apache.org>
Sent: Monday, November 13, 2000 11:37 PM
Subject: HTTP proxy patch


> Hi all.
>
> I made a HTTP proxy patch which can connect to the SOAP server
> via the HTTP proxy.
>
> Most HTTP browsers support the HTTP access via the proxy server.
> Apache SOAP 2.0 did not support the HTTP proxy server
> though using the HTTP communication.
>
> Please call the following before invoking the Call object.
>
> Example:
>
>  HTTPUtils.SetProxy("proxy", 10080); // set static variables
>
> Thanks
> --
> ITO Akinori
> akito@paso.fujitsu.co.jp
>
> xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java 1.7
> *** /tmp/T05WaOoH       Tue Nov 14 11:15:16 2000
> --- HTTPUtils.java      Tue Nov 14 11:14:34 2000
> ***************
> *** 74,79 ****
> --- 74,81 ----
>     private static final String HEADER_CONTENT_TYPE = "Content-Type";
>     private static final String HEADER_CONTENT_LENGTH = "Content-Length";
>     private static final int    HTTP_DEFAULT_PORT = 80;
> +   private static String HTTP_PROXY_HOST = null;
> +   private static int    HTTP_PROXY_PORT = 80;
>
>     /**
>      * An instance of this class is returned by post.
> ***************
> *** 119,125 ****
>         if (port < 0)  // No port given..use HTTP default which is pry 80
:-)
>           port = HTTP_DEFAULT_PORT;
>
> !       Socket s = new Socket (url.getHost (), port);
>         s.setSoTimeout(timeout);
>         out = new PrintWriter (s.getOutputStream ());
>         in = new BufferedReader (new InputStreamReader (s.getInputStream
()));
> --- 121,132 ----
>         if (port < 0)  // No port given..use HTTP default which is pry 80
:-)
>           port = HTTP_DEFAULT_PORT;
>
> !       Socket s;
> !       if (HTTP_PROXY_HOST == null) {
> !         s = new Socket (url.getHost (), port);
> !       } else {
> !         s = new Socket (HTTP_PROXY_HOST, HTTP_PROXY_PORT);
> !       }
>         s.setSoTimeout(timeout);
>         out = new PrintWriter (s.getOutputStream ());
>         in = new BufferedReader (new InputStreamReader (s.getInputStream
()));
> ***************
> *** 129,136 ****
>       }
>
>       /* send it out */
> !     out.print (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION +
> !                "\r\n");
>       out.print (HEADER_HOST + ": " + url.getHost () + ':' + port + "\r\n");
>       out.print (HEADER_CONTENT_TYPE + ": " + contentType + "\r\n");
>       out.print (HEADER_CONTENT_LENGTH + ": " + content.length () + "\r\n");
> --- 136,148 ----
>       }
>
>       /* send it out */
> !     if (HTTP_PROXY_HOST == null) {
> !       out.print (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION
+
> !                  "\r\n");
> !     } else {
> !       out.print (HTTP_POST + " " + url.toString() + " HTTP/" +
HTTP_VERSION +
> !                  "\r\n");
> !     }
>       out.print (HEADER_HOST + ": " + url.getHost () + ':' + port + "\r\n");
>       out.print (HEADER_CONTENT_TYPE + ": " + contentType + "\r\n");
>       out.print (HEADER_CONTENT_LENGTH + ": " + content.length () + "\r\n");
> ***************
> *** 195,198 ****
> --- 207,221 ----
>       return new Response (statusCode, statusString, respHeaders,
>                            respContentLength, respContentType, in);
>     }
> +
> +   /**
> +    * Set HTTP proxy.
> +    *
> +    * @param host the HTTP proxy host or null if no proxy.
> +    * @param port the HTTP proxy port
> +    */
> +   public static void SetProxy(String host, int port) {
> +     HTTP_PROXY_HOST = host;
> +     HTTP_PROXY_PORT = port;
> +   }
>   }


Re: HTTP proxy patch

Posted by Sanjiva Weerawarana <sa...@watson.ibm.com>.
Thanks for sending this - I committed it with a minor change: method
name changed to setProxy instead of SetProxy. Hope that's ok!

When we do get around to updating the docs this needs to be described
as this is a very useful piece of functionality for many people.

Sanjiva.

----- Original Message -----
From: "Akinori ITO" <ak...@paso.fujitsu.co.jp>
To: <so...@xml.apache.org>
Sent: Monday, November 13, 2000 11:37 PM
Subject: HTTP proxy patch


> Hi all.
>
> I made a HTTP proxy patch which can connect to the SOAP server
> via the HTTP proxy.
>
> Most HTTP browsers support the HTTP access via the proxy server.
> Apache SOAP 2.0 did not support the HTTP proxy server
> though using the HTTP communication.
>
> Please call the following before invoking the Call object.
>
> Example:
>
>  HTTPUtils.SetProxy("proxy", 10080); // set static variables
>
> Thanks
> --
> ITO Akinori
> akito@paso.fujitsu.co.jp
>
> xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java 1.7
> *** /tmp/T05WaOoH       Tue Nov 14 11:15:16 2000
> --- HTTPUtils.java      Tue Nov 14 11:14:34 2000
> ***************
> *** 74,79 ****
> --- 74,81 ----
>     private static final String HEADER_CONTENT_TYPE = "Content-Type";
>     private static final String HEADER_CONTENT_LENGTH = "Content-Length";
>     private static final int    HTTP_DEFAULT_PORT = 80;
> +   private static String HTTP_PROXY_HOST = null;
> +   private static int    HTTP_PROXY_PORT = 80;
>
>     /**
>      * An instance of this class is returned by post.
> ***************
> *** 119,125 ****
>         if (port < 0)  // No port given..use HTTP default which is pry 80
:-)
>           port = HTTP_DEFAULT_PORT;
>
> !       Socket s = new Socket (url.getHost (), port);
>         s.setSoTimeout(timeout);
>         out = new PrintWriter (s.getOutputStream ());
>         in = new BufferedReader (new InputStreamReader (s.getInputStream
()));
> --- 121,132 ----
>         if (port < 0)  // No port given..use HTTP default which is pry 80
:-)
>           port = HTTP_DEFAULT_PORT;
>
> !       Socket s;
> !       if (HTTP_PROXY_HOST == null) {
> !         s = new Socket (url.getHost (), port);
> !       } else {
> !         s = new Socket (HTTP_PROXY_HOST, HTTP_PROXY_PORT);
> !       }
>         s.setSoTimeout(timeout);
>         out = new PrintWriter (s.getOutputStream ());
>         in = new BufferedReader (new InputStreamReader (s.getInputStream
()));
> ***************
> *** 129,136 ****
>       }
>
>       /* send it out */
> !     out.print (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION +
> !                "\r\n");
>       out.print (HEADER_HOST + ": " + url.getHost () + ':' + port + "\r\n");
>       out.print (HEADER_CONTENT_TYPE + ": " + contentType + "\r\n");
>       out.print (HEADER_CONTENT_LENGTH + ": " + content.length () + "\r\n");
> --- 136,148 ----
>       }
>
>       /* send it out */
> !     if (HTTP_PROXY_HOST == null) {
> !       out.print (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION
+
> !                  "\r\n");
> !     } else {
> !       out.print (HTTP_POST + " " + url.toString() + " HTTP/" +
HTTP_VERSION +
> !                  "\r\n");
> !     }
>       out.print (HEADER_HOST + ": " + url.getHost () + ':' + port + "\r\n");
>       out.print (HEADER_CONTENT_TYPE + ": " + contentType + "\r\n");
>       out.print (HEADER_CONTENT_LENGTH + ": " + content.length () + "\r\n");
> ***************
> *** 195,198 ****
> --- 207,221 ----
>       return new Response (statusCode, statusString, respHeaders,
>                            respContentLength, respContentType, in);
>     }
> +
> +   /**
> +    * Set HTTP proxy.
> +    *
> +    * @param host the HTTP proxy host or null if no proxy.
> +    * @param port the HTTP proxy port
> +    */
> +   public static void SetProxy(String host, int port) {
> +     HTTP_PROXY_HOST = host;
> +     HTTP_PROXY_PORT = port;
> +   }
>   }