Anyone help with emulating Java URLConnection?

From: Jochen Daum (jochen.daum_at_cabletalk.co.nz)
Date: 04/30/04


Date: Fri, 30 Apr 2004 15:04:10 +1200

Hi,

I have to emulate a "file upload" to a Java Servlet which is done with
the class URLConnection.

The java source basically does

URLConnection conn = theurl.openConnection("https://somesite");
w = conn.getOutputStream();
w.write(...)

A thing I'm unclear of is if this connection is actually encrypted
over SSL. The other thing is if this just sends the bytes or also any
HTTP headers

I can think of three possible solutions:

Use fopen:

- I would have to recompile PHP for that and also it says:

"failed to open stream: HTTP wrapper does not support writeable
connections"

Use sockets:

- I have bad experiences with it being unreliable, if you read from
the connection and there are no bytes send. The timeout doesn't seem
to work. Also, I wouldn't know how the SSL would work with that.

Use curl:

- I would expect curl to always send a HTTP header, so I don't know if
its compatible.

Anyone here with Java experience that could help me?

Jochen

-- 
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/


Relevant Pages

  • Re: Anyone help with emulating Java URLConnection?
    ... >> the connection and there are no bytes send. ... I wouldn't know how the SSL would work with that. ... if this connection contains HTTP headers and if and what ... Jochen Daum - Cabletalk Group Ltd. PHP DB Edit Toolkit -- PHP scripts for building database editing interfaces. ...
    (comp.lang.php)
  • Re: [VulnWatch] The Java applet sandbox and stateful firewalls
    ... Is the Java Sandbox able to create outgoing connections on ports like 445? ... >This is a passive attack. ... The applet initiates a TCP connection back to the originating ... > A FTP server on the same machine that hosts the originating web ...
    (Bugtraq)
  • [Full-disclosure] Re: [VulnWatch] The Java applet sandbox and stateful firewalls
    ... Is the Java Sandbox able to create outgoing connections on ports like 445? ... >This is a passive attack. ... The applet initiates a TCP connection back to the originating ... > A FTP server on the same machine that hosts the originating web ...
    (Full-Disclosure)
  • Re: HTML "scrape" causes loss of query string in URL
    ... >> in PHP with several PHP scripts interacting with one Java servlet, ... >> which interacted with several Java classes. ... > process to go from PHP to JSP. ...
    (comp.lang.java.help)
  • Re: e-commerce portal
    ... haven't had a single site that sees a need for this sort of hardening. ... Java anymore. ... PHP is a technology that has gotten a harsh rap due to large security ... Marketing at its worse, eh? ...
    (comp.databases.pick)