I did some reading on this issue and I found that, at one point, what I want was possible. In comment #3, this shows up:
request.post = {
Name : "Jonathan Doe",
Age : "23",
Formula : "a + b == 13%!"
}
Now, this is exactly what I want to get when I send a POST request to my PhantomJS webserver.
I'm sending it like this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "localhost:8585");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'ajaxUrl' => $ajaxUrl,
'analysisFile' => $analysisFile,
'businessId' => $businessId,
'website' => $website
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
..but the request I get just looks like this (after JSON.stringify
):
{ "headers" : { "Accept" : "*/*",
"Content-Length" : "555",
"Content-Type" : "multipart/form-data; boundary=----------------------------ad33c9f28b99",
"Expect" : "100-continue",
"Host" : "localhost:8585"
},
"httpVersion" : "1.1",
"method" : "POST",
"post" : "------------------------------ad33c9f28b99
Content-Disposition: form-data; name=\"ajaxUrl\"
http://localhost/website/ajax.php
------------------------------ad33c9f28b99
Content-Disposition: form-data; name=\"analysisFile\"
C:\\xampp\\htdocs\\website\\phantom\\get_site_info.js
------------------------------ad33c9f28b99
Content-Disposition: form-data; name=\"businessId\"
67
------------------------------d33c9f28b99
Content-Disposition: form-data; name=\"website\"
http://www.website.com/
------------------------------ad33c9f28b99--
",
"url" : "/"
}
As you can see, there's no POST object, just a large string that has all of the POST data in it. Is it the way I'm sending it via cURL? I'm pretty unfamiliar with that, and the cURL code I got from here.
I'm running phantomjs 1.9.1 with casperjs 1.1.0-DEV, if that helps.