I'm using the stats plugin for wordpress which uses a core wordpress class IXR_Client in class-IXR. Although according to documentation it uses the proxy config found in wp-config.php I see no way it can as it uses the same address for host as it does in fsockopen (looking at fsockopen it should be the proxy address)
I've modified the fsockopen to point to my proxy and it does receive a response now from the proxy although 'TCP_DENIED/400 4139 POST error:invalid-request - NONE/- text/html' comes up in the proxy logs and the proxy returns an error. I have a feeling I'm not wrapping the request right for the proxy.
The request: (some things changed)
POST /xmlrpc.php HTTP/1.0 Host: wordpress.com Content-Type:
text/xml User-Agent: The Incutio XML-RPC PHP Library Content-Length: 1770 <?xml
version="1.0"?> <methodCall> <methodName>wpStats.check_key</methodName> <params>
<param><value><string>123456789012</string></value></param> <param><value><struct>
<member><name>host</name><value><string>thedomainoftheblog.com</string></value></member>
<member><name>path</name><value><string>/</string></value></member>
<member><name>admin_bar</name><value><string>1</string></value></member>
<member><name>wp_me</name><value><string>1</string></value></member>
<member><name>reg_users</name><value><string></string></value></member>
<member><name>footer</name><value><string>1</string></value></member>
<member><name>version</name><value><string>7</string></value></member>
<member><name>error</name><value><string></string></value></member>
<member><name>blogname</name><value><string>THE | BLOG NAMEFUL</string></value></member>
<member><name>blogdescription</name><value><string>blogs name norma
l</string></value></member><member><name>siteurl</name>
<value><string>http://thedomainoftheblog.com</string></value></member>
<member><name>gmt_offset</name><value><string>0</string></value></member>
<member><name>timezone_string</name><value><string></string></value></member>
<member><name>stats_version</name><value><string>7</string></value></member>
<member><name>stats_api</name><value><string>jetpack</string></value></member>
<member><name>page_on_front</name><value><string>0</string></value></member>
<member><name>permalink_structure</name><value>
<string>/%year%/%monthnum%/%day%/%postname%/</string></value></member>
<member><name>category_base</name><value><string></string></value></member>
<member><name>tag_base</name><value><string></string></value></member> </struct></value></param> </params></methodCall>
If you need more information let me know.
Cheers
The trick seems to be to add http://your.domain.name/ on the POST request (i.e. not only POST/name-of-file, as class-IXR.php has by default), at least according to the following link: http://thedeadone.net/how-to/livejournal-and-wordpress/
I've tried it out and it certainly works.
There are a few proxy-related constants in WP, as well as a whole bunch of other constants used in wp-includes/class-http.php. Have you tried to set any or all of them? e.g.:
WP_PROXY_HOST
WP_PROXY_PORT
WP_PROXY_USERNAME
WP_PROXY_PASSWORD
WP_PROXY_BYPASS_HOSTS
Related
we're using a custom built cart system and during high loads our payment system (Worldpay) times out.
When this happen we receive an email containing the POST request that failed, and this is a .txt file done like the following:
POST /index.php?xxx=yyy&zzz=xxx HTTP/1.0
Content-Length: 917
Host: ourdomain.com
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
User-Agent: WJHRO/1.0 (WorldPay Java HTTP Request Object)
parameter1=value¶meter2=value2
How can I actually quickly resend this request to my server so it can register the payment now that the load is more normal? I have this in a .txt file, is there a quick way to do it using this file as it is? Curl? Browsers? In a way so I can see the response to check that all is ok.
Thanks so much!
Depending on the needs you have exposed, it is likely that tools such as POSTMAN could help you, allow you to send http requests through an intuitive interface, you can use the various parameters, that are sent to you in the file you mentioned and run the same request check for any errors.
I'm building an api that receives incoming webhooks from external parties. Post requests to my application lack a body in some cases. In my logs I see the incoming request with the following header:
Accept: */*
Content-Length:
Content-Type: application/json
As you can see the content-length is empty.
I cannot reproduce the problem. What I've tried thus far:
The request payload is only missing coming from a specific third party. If however, I provide this third party with a different callback url like request bin, the payload is not missing.
Connected this party source to our test environment. Which has exactly the same configuration (checked the entire php.ini) and the same version of our software. On our test server, requests are received with payload.
When sending post requests with Postman to our production environment, webhooks are received with payload.
Both test and production are https. I've tried sending http requests to our production server to see what happens, and I get an error as expected and no received headers in our logs.
Checked the php post_max_size, which is on 24M.
When creating a callback.php file in my public folder, and have the third party send it's webhooks to this destination, I am able to write the results to a log with the following code, which includes a payload. If I to output php://input later on in my Laravel application, it doesn't work:
$postdata = file_get_contents("php://input");
$file = fopen("webhook.log","w");
echo fwrite($file,$postdata);
fclose($file);
Both servers are running on the same php version (php7), and I am at a loss as to what to try next.
Found it! The problem was a port 80 to 443 redirect in a vhost configuration. I earlier dismissed redirects - which seem to be a common source of missing payloads in post requests - as possible cause; I had made a test script which succesfully received payloads on this very same server.
However, I had placed this test script in the servers public folder, which was not subject to the same redirects as was the root of my application. After removing the redirect, payloads where received as expected.
I'm accessing the Magento SOAP API v2 with PHP's SoapClient
$soap_client = new SoapClient($wsdl_url, array('trace' => 1));
The wsdl url is http://www.example.org/index.php/api/v2_soap/?wsdl=1
Opening the url in the browser results in a valid xml document.
However when I access that same url with the SoapClient I get the following error message from $soap_client->__getLastResponse():
Invalid webservice adapter specified.
Looking at the request headers with $soap_client->__getLastRequestHeaders() shows that the call is being redirected to http://www.example.org/api/v2_soap/index/:
POST /api/v2_soap/index/ HTTP/1.1
Host: www.example.org
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.3
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:Mage_Api_Model_Server_V2_HandlerAction"
Content-Length: 542
Calling that url (http://www.example.org/api/v2_soap/index/) in the browser outputs the same error message that the SoapClient returns (Invalid webservice adapter specified.)
How is it possible that the SoapClient is being redirected while a normal http request works fine?
Any help greatly appreciated
The effect of MultiViews is as follows: if the server receives a
request for /some/dir/foo, if /some/dir has MultiViews enabled, and
/some/dir/foo does not exist, then the server reads the directory
looking for files named foo.*, and effectively fakes up a type map
which names all those files, assigning them the same media types and
content-encodings it would have if the client had asked for one of
them by name. It then chooses the best match to the client's
requirements.
MultiView Docs
I have to integrate a 3rd party system into my PHP app. I'm using cURL. The documentation says I have to send a soap envelope to the server, but in their example I found the following HTTP header as a correct request:
POST /CLI/ HTTP/1.1
Host: example.com
What's that CLI in the header? How can I send such a request from PHP?
Thanks for your help.
It's just the resource being requested,
GET /index.php
POST /index.php
IN your case: POST http://example.com/CLI/
http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
The topic is a bit strange, let me express myself.
I used this method to generate post requests:
http://www.jonasjohn.de/snippets/php/post-request.htm
thats ok, but after a size, I realized the datas gets changes a little, there are unwanted white spaces. Only in case of a bigger size, + a "chunked" flag appeared.
I change the Http/1.1 protocol to Http/1.0 and now the transfers look good!
But is there any backward, pitfalls?
Well there are a number of important differences between http 1.0 and 1.1 of course, look at this article for an overview.
One that I can directly spot as affecting your code is
// send the request headers:
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
The Host header field doesn't exist in http 1.0, and that could affect your ability to post to servers that host multiple domains and/or subdomains via name based virtual hosting - the server won't know what domain you're calling.
As a general note, writing a post request this way is a nice exercise and it's always good to know what goes on under the hood, but for production purposes I'd use a full-blown, well tested mechanism like cURL
And for reference:
rfc 1945 defines http 1.0
rfc 2616 defines http 1.1