Hi Kelly,
On Thu, 29 Apr 2004 23:59:53 -0400, Kelly Thompson
<kt*************@hotmail.com> wrote:
On Fri, 30 Apr 2004 15:04:10 +1200
Jochen Daum <jo*********@cabletalk.co.nz> wrote:
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 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.
Why not?
Well it didn't when I used sockets to access a serial modem. If the
modem didn't send a byte, it would just never time out.
I think that in a few words you want a function do_post(). If PHP
was compiled against SSL libraries, then fsockopen() will support
``ssl://''. A rough implementation:
(...)
I think I'm missing that, but thats a different problem.
$host = 'example.com';
$path = '/path/to/script';
$port = 443 /* ssl */
(..doing a HTTP POST...)
because of the Java source I have:
public void putFile(String thedir, String thefile) throws Exception {
System.out.println(getStorePath()+thefile);
URL theurl = new URL(getStorePath()+thefile.replace(' ','_'));
System.out.println(theurl.toString());
URLConnection conn = theurl.openConnection();
// setting the authorization header doesn't seem to work - it
remains as null
// and then causes errors
// conn.setRequestProperty("Authorization","Basic "+auth);
conn.setDoOutput(true);
URL newurl = conn.getURL();
System.out.println(newurl.toString());
// conn.connect();
connect(new FileInputStream(new File(thedir,
thefile)),conn.getOutputStream());
BufferedReader in = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String response = in.readLine();
System.out.println(response);
I'm unsure, if this connection contains HTTP headers and if and what
request method is used.
I also can't quite figure out what the fieldname might be. There is
nothing in connect(in,out) that does anything else but copying. I have
tried to just post 'thefile' with curl:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
//curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
//curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $thefile);
curl_setopt($ch, CURLOPT_USERPWD, "xxx:xxx");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
but I get an 503 as an answer.
Thanks for your help so far.
Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/