![](/img/trans.png)
[英]what controls the time a request is processed on an apache2.2/php5 web service
[英]cURL, php request_headers from Apache2.2 to Oracle App Server
我已经把头撞了这么久。 我希望有人可以帮助我解决这个问题。 我现在不确定我的问题是否是由cURL,php,Apache,Oracle或大脑放屁引起的。
我正在尝试发布到Oracle服务器上的表单。 用手,我可以创建一个类似于GET的网址,以显示正确的页面。 我想执行POST来隐藏变量(可能有很多),因为原始表单的方法是POST。 无论哪种方式,我都无法通过我的php / cURL程序获得响应。
我的具体问题:
这是我当前的代码:
*<?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);
?>*
------------这是当前的日志记录-------------
从我的错误转储中:
-------------- 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
从我的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"*
为什么要执行GET?
HTML代码返回:
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
尝试
$fields = array(
'LAST_NAME' => 'MacBlahBlah',
'FIRST_NAME' => 'Blahberina',
'CONTAINS' => 'Y',
... and more fields ...
);
$url_enc_fields = http_build_query($fields);
接着
curl_setopt($ch,CURLOPT_POST,count($fields)); // Apparently futile
curl_setopt($ch,CURLOPT_POSTFIELDS,$url_enc_fields);
我没有检查这些更改,但这是我通常这样做的方式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.