I've bumped my mind about this lengthy enough. I really hope someone might help me figure this out. I am unsure any longer whether my troubles are triggered by cURL, php, Apache, Oracle or perhaps a brain fart.

I am attempting to publish to some form with an Oracle server. Manually, I can produce a GET-like url which will mention the right page. I wish to do Publish to cover the variables (and there might be many of them) and since the coming initially from form's technique is Publish. In either case I can not obtain the response via my php/cURL program.

My specific questions:

  • The apparent one, why does not it work?
  • Why can one perform the request manually and never by program?
  • How come the access.log possess a Enter there?
  • Exactly why is my request header being rewritten to incorporate the /Father/plan/application from the Oracle server?
  • Will my programming ego be exactly the same?

Here's my current code:

*<?php

$error_dump = 'stderr.txt';
$error_dump_handle = fopen($error_dump,'a');
$ch = curl_init();
$url = 'http://www2.blah.com/pls/blah/blah.blaQuery';
$url_enc_fields = array(
    'LAST_NAME'  => 'MacBlahBlah',            
    'FIRST_NAME' => 'Blahberina',          
    'CONTAINS' => 'Y',
        ... and more fields ...
    );              
$url_enc_fields = http_build_query($url_enc_fields);

//$url = $url.'?'.$url_enc_fields;  //previous GET attempt
$content_length = strlen($url_enc_fields);// number of bytes
$content_length = 'Content-Length:' . $content_length;
$headers = array(
    'Request: POST ' . $url_enc_fields . 'HTTP/1.1',  //An attempt to force the request
    'Accept: */*',
    'Content-Type: application/x-www-form-urlencoded',
    'Referer:http://blah.com/pls/blah/blah.startup?code1=MM&code2=bleep',               
    'Expect: ',
    $content_length
    );

curl_setopt($ch,CURLOPT_HEADER,1); 
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLINFO_HEADER_OUT,TRUE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,FALSE); 
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);  // one of many guesses
curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE);
// NOTE: no cookies or passwords involved             
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,180);
curl_setopt($ch,CURLOPT_TIMEOUT,180);

curl_setopt($ch,CURLOPT_VERBOSE,TRUE);
curl_setopt($ch,CURLOPT_STDERR,$error_dump_handle);
curl_setopt($ch,CURLOPT_ENCODING,'chunked'); // Added because the response was chunked, no difference
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,TRUE); // Apparently futile
curl_setopt($ch,CURLOPT_POSTFIELDS,$url_enc_fields);             
$postResult = curl_exec($ch);
$info = curl_getinfo($ch);   
$pretty_info = print_r($info,true);

> echo '<br/><pre>'; print_r($info); print_r($url_enc_fields);
> print_r($headers);

echo '</pre>';
$now_time = getdate();$format = '-------------- %f -----------';
fprintf($error_dump_handle,$format,$now_time[0]);
fprintf($error_dump_handle,$pretty_info);   
fprintf($error_dump_handle,curl_error($ch));    
fclose($error_dump_handle); 
curl_close($ch); 
?>*                                              

------------ This is actually the current logging -------------

From the error dump:

-------------- 1323725891.000000 -----------Array
(
    [url] => http://www2.blah.com/pls/blah/blah.blaQuery
    [content_type] => text/html; charset=iso-8859-1
    [http_code] => 404
    [header_size] => 205
    [request_size] => 601
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.203
    [namelookup_time] => 0
    [connect_time] => 0.078
    [pretransfer_time] => 0.078
    [size_upload] => 146
    [size_download] => 336
    [speed_download] => 1655
    [speed_upload] => 719
    [download_content_length] => -1
    [upload_content_length] => 0
    [starttransfer_time] => 0.203
    [redirect_time] => 0
    **[request_header] => POST /pls/blah/blah.blaQuery HTTP/1.1**
Host: blah.com
Accept-Encoding: chunked
Request: POST LAST_NAME=MacBlahBlah&FIRST_NAME=Blahberina&CONTAINS=Y&...some other fields... HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded
Referer:http://blah.com/pls/wllpub/blah.startup?code1=MM&code2=bleep
Content-Length:146

From the Apache access.log:

*##.##.##.## - - [12/Dec/2011:14:38:06 -0700] "GET /cgi-bin/mydir/mysubmit_form.php HTTP/1.1" 200 2698 "-" "Mozilla/5.0 (Windows NT 6.0; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0"*

Why do carrying out a GET?

The Web coding came back:

http://www2.blah.com/pls/blah/blah.blaQuery
HTTP/1.1 404 Not Found
Date: Mon, 12 Dec 2011 22:03:53 GMT
Server: Oracle-Application-Server-10g/10.1.2.2.0 Oracle-HTTP-Server
Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1
Not Found
The requested URL pls/blah/blah.blaQuery was not found on this server.

Oracle-Application-Server-10g/10.1.2.2.0 Oracle-HTTP-Server Server at www2 Port 80