| Recommend this page to a friend! |
| PHP HTTP protocol client | > | All threads | > | <h1>Bad Request</h1> | > | (Un) Subscribe thread alerts |
| |||||||||||||||
When I load a url with an HTTP GET request I get a <h1>Bad Request</h1> returned. When I place the same url and get arguments in a browser i get the correct response from the webpage. Is there something i need to set to allow for a redirect or something not sure why this would be happening?
Thanks 12.111.80.134/joe/zaner/matrix/lead ...require("http.php"); include('sasl.php'); function load_url( $url ) { $returnvalue = ""; set_time_limit(0); $http=new http_class; $http->timeout=0; $http->data_timeout=0; $http->debug=0; $http->html_debug=0; $http->follow_redirect=0; $http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $error=$http->GetRequestArguments($url,$arguments); $error=$http->Open($arguments); if($error) return "An Error Occurred: $error"; $error=$http->SendRequest($arguments); if($error) return "An Error Occurred: $error"; $headers=array(); $error=$http->ReadReplyHeaders(&$headers); if($error) return "An Error Occurred: $error"; for(Reset($headers),$header=0;$header<count($headers);Next($headers),$header++) { $header_name=Key($headers); if(GetType($headers[$header_name])=="array") { for($header_value=0;$header_value<count($headers[$header_name]);$header_value++) if ($header_name == "location") { return load_url($headers[$header_name][$header_value]); } } else if ($header_name == "location") { $redir = $headers[$header_name]; $regexp = "http(s?)\:\/\/(.*)\/(.*)"; if(preg_match("/$regexp/siU", $redir, $matches)) { $url = $redir; return load_url($url); } else { if(preg_match("/$regexp/siU", $url, $matches)) { $url = "http://".$matches[2].str_replace(" ", "%20", $redir); return load_url($url); } else { return "An Error Has Occurred."; } } } } for(;;) { $error=$http->ReadReplyBody($body,1000); if ($error!="" || strlen($body)==0) break; $returnvalue .= $body; } return $returnvalue; } $url = "http://12.111.80.134/joe/zaner/matrix/leadSorting/applyMatrixnew.php?campaign_id=79&subcampaign_id=4877&product=6&p_descr=1&sit_fixed=y&leadquality=8&form_from=postin&borrower_fname=Test&borrower_lname=Test&prop_address=5115+Wilshire+Blvd&prop_city=Los+Angeles&prop_state=AK&prop_zip=99515&email=testlead42%40getseenmedia.com&d_area=323&d_phone=4244665&dw_area=323&dw_phone=4244665&cred_hist=2&p_value=600000&pay_1m=2000&mort1_monthsbehind=4%2B&bal_1m=200000&loan_amount=200000&monthlypay_afford=1500&f_date=8-25-2009&mort1_lender=Wells+Fargo"; $body = load_url($url); echo($body);
The problem is that server is returning a malformed URL for redirection, as it contains spaces.
I just uploaded a new version of the class that fixes such malformed URLs. |
info at phpclasses dot org.
