zeeshanhashmi — 2012-11-06T02:08:01-05:00 — #1
This is the header that my PHP script sends via fsockopen
POST /xyz/add.aspx HTTP/1.0
User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
But it returns:
Bad Header (Invalid Header Name)
I have to do it without cURL
Please tell me what is wrong ?
logic_earth — 2012-11-06T02:14:29-05:00 — #2
You have white space between Content-Type and Content-Length which should not be there.
zeeshanhashmi — 2012-11-06T02:52:04-05:00 — #3
Hi thanks for your reply.
I just removed the blank line, but the result stays the same.
zeeshanhashmi — 2012-11-06T07:34:39-05:00 — #4
Please help ! so much views and no one replied apart from just 1 ?
cpradio — 2012-11-06T07:50:26-05:00 — #5
You are using = instead of : in several of your headers which isn't allowed (based on what I see at fsocketopen)
zeeshanhashmi — 2012-11-06T09:36:15-05:00 — #6
Thanks YES, I already fixed that and also added POSTDATA: etc. That thing worked now.
But, now, the new issue is : I get this message:
<b>Warning</b>: fgets(): SSL: The operation completed successfully.
Please Help !
cpradio — 2012-11-06T09:38:06-05:00 — #7
Post your code, as I can't tell you what that means without seeing it.
zeeshanhashmi — 2012-11-06T09:46:55-05:00 — #8
Here is the code:
$headers = "POST /abc/add.aspx HTTP/1.1\\r\
$headers .= "Host: mysite.com\\r\
$headers .= "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0\\r\
$headers .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\
$headers .= "Accept-Language: en-US,en;q=0.5\\r\
$headers .= "Accept-Encoding: gzip, deflate\\r\
$headers .= "Connection: keep-alive\\r\
$headers .= "Referer: https://www.mysite.com/abc/add.aspx\\r\
$headers .= "Cookie: ASP.NET_SessionId=$ASPSESS\\r\
$headers .= "Content-Type: multipart/form-data; boundry=".$d.$boundary."\\r\
$headers .= "Content-Length: $bodyLength\\r\
$headers .= "POSTDATA: $bodyString";
$fp = fsockopen("ssl://www.mysite.com", 443, $errno, $errstr);
$response = '';
$response .= fgets($fp);
cpradio — 2012-11-06T10:01:47-05:00 — #9
What version of PHP are you running this on? A google search I ran seems to indicate this is an issue with lower versions of PHP 4, or any version of PHP that isn't compiled with the openssl option. I'm not 100% certain yet which may be your case, or if there is another reason for this warning to be generated.
zeeshanhashmi — 2012-11-06T10:07:37-05:00 — #10
I have latest PHP version with OPENSSL installed. If openssl is not installed it shows other error message, not the one i posted.