Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added curl transport #2

Merged
merged 6 commits into from
Aug 2, 2012
Merged

added curl transport #2

merged 6 commits into from
Aug 2, 2012

Conversation

cryptocompress
Copy link
Contributor

cannot test as http://validator.xmlrpc.com/ is down :(

@lstrojny
Copy link
Owner

lstrojny commented Aug 2, 2012

Thanks for your contribution! Could you add CurlTransport to the integration test? The integration tests run against a node.js XML/RPC server, so all you need is node.js installed and than run the ./vendor.sh script. Adding it to the integration test suite will show two things: a) the check for the response is too generic, as it does not check for the HTTP response code and throws a specific exception there and b) there is not really a need for a specific unit test. The integration test will test your transport against every possible combination of serializers and parsers, so if this works you can be really certain it’s good :)

Besides that I would suggest creating the curl handle in the constructor and just setting the URL as a parameter in send(). That way you could reuse the handle with the second request.

public function send($uri, $payload)
{
curl_setopt($this->handle, CURLOPT_URL, $uri);
curl_setopt($this->handle, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every curl_setopt() call besides CURLOPT_URL could be done in the constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry but i disagree. think of curl_multi_exec. this is request specific.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s more a really small optimization. FXMLRPC reuses client instances. So you save a few cycles by only doing the general setopt calls once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really don't like to do work in constructor... but here it is :)

@cryptocompress
Copy link
Contributor Author

integration tests) missed this. cannot run tests as i have none of this transports :( try to get travis green now :)
a) removed check on http-status-code on copy-pasting source from my curl client. readd it. i guess it should not throw Exception on 2xx? or maybe 3xx too?
b) deleted this test and reused handle. but don't think it is worth it as it is not as multi handle.


$response = curl_exec($this->handle);
$code = curl_getinfo($this->handle, CURLINFO_HTTP_CODE);
if (substr($code, 0, 1) != 2 || $response === false || strlen($response) < 1) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check for exactly 200 here, as everything else is not allowed by XML/RPC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@lstrojny
Copy link
Owner

lstrojny commented Aug 2, 2012

Thanks again. See the rest of my comments.

@cryptocompress
Copy link
Contributor Author

travis passed... enjoy :)

@lstrojny
Copy link
Owner

lstrojny commented Aug 2, 2012

Thanks for your patience!

@lstrojny lstrojny merged this pull request into lstrojny:master Aug 2, 2012
@cryptocompress
Copy link
Contributor Author

it was my pleasure :)

lstrojny added a commit that referenced this pull request Aug 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants