-
Notifications
You must be signed in to change notification settings - Fork 24
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
Use higher level http library than curl? #49
Comments
➕ for Requests over HTTP_Request2, but I'd like a few more |
If we want to add more PEAR dependencies we need a way to manage them and install them easily. Maybe I'm just a grumpy old man but I don't understand why people don't just use curl. |
Comedy composer option over PEAR, which should make @patcon all sorts of On Sat, Sep 21, 2013 at 3:33 PM, Josh Koenig [email protected]:
|
haha I think I'm excited, although not sure what "comedy" autocorrected from...? |
Sorry @patcon, "comedy [option]" is (if I recall correctly) an anachronistic reference to some old internet forums from more than a decade ago, wasn't meant to be derogatory :-) To clarify, I'm saying Composer > PEAR. |
waves 👋 I'm the Requests developer, and I'd love to see you guys switch over, so let me know if you have any questions! (Working with cURL sucks, so anything that helps you guys spend more time making awesome features instead of dealing with stupid cURL nonsense is awesome.) Requests is available via Composer ( |
Whoa awesome! Personally, I kind of like dealing with cURL, but I'm like On Sun, Sep 22, 2013 at 9:47 PM, Ryan McCue [email protected]:
Josh Koenig |
From the Request GitHub page:
Does this mean the API will use cURL first, and fallback on fsockopen if cURL isn't available? Just thinking out loud here on some considerations:
|
Correct, it uses cURL by default and then falls back.
cURL is on about 80-90% of hosts from our testing.
Slightly inaccurate now, Requests now uses
Guzzle is also a good choice, but does require cURL. Requests is all about maximum compatibility and unit tests coverage, whereas Guzzle is about providing a fluent interface for REST requests (that is, Requests focuses on being a HTTP client, Guzzle focuses on being a REST client, but you can still build one with Requests very easily). |
@rmccue very cool, appreciate the support and the comprehensive answers! I'm going to investigate / try Requests after I take care of some tests and documentation. |
Ok, so we're on composer now. Next step will be looking at a meta-library. This could help for unit testing too: it is probably easier to mock out Requests (or another similar tool) vs cUrl. |
Using cURL leaves out all the folks stuck behind corporate proxies (think Intel, my company for example). Yes, it's dead simple until you have to logically know if you're not behind a proxy (when working from home and not VPN'ed to work), and when I am in the office and the proxy is keeping me from "getting stuff done." Example, I attempted to hack in environment-variable-based proxy settings into terminus, only to notice that terminus.drush.inc sets up cURL individually five separate times and I would have to hack in my solution the same number of times. Not super cool and gave up and rode my bike home to use it but I cannot do this everyday. |
A suggestion I offer to any company wanting to work with large corporations is to put up a web proxy/firewall/socks proxy and then try and make any of your stuff work. If it works for you after all that, then your corporate customers will probably be happy too. |
@gwynnebaer I hear what you're saying. I'm going to make https://github.com/rmccue/Requests a priority, which includes proxy support. |
Not done, but check out the requests branch if you are so inclined. https://github.com/pantheon-systems/terminus/commits/requests |
Might have a blocker, some of the DELETE commands are expecting POST-style data, and that's explicitly not allowed in Requests. Reaching out to the dev to determine if there's a feasible workaround, otherwise will have to look elsewhere. Otherwise, it's implemented. |
Or we can change the API.
|
@davidstrauss Correct me if I'm wrong, but based on my research this actually seems limited to just one REST operation - code-branch DELETE. The other DELETE operations get their context from the path. If that's accurate, then an API change a lot more feasible. |
You should be able to send this by using |
That was one of my experiments. I'll create an issue, thanks for the follow-up! |
In case anyone's curious - WordPress/Requests#91 |
It's actually not in a POST field. It's in the request body.
|
@davidstrauss the way we're currently doing it: if ($data) {
// The $data for POSTs, PUTs, DELETEs are sent as JSON.
if ($method === 'POST' || $method === 'PUT' || $method === 'DELETE') {
$data = json_encode(array('data' => $data));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
array_push($headers, 'Content-Type: application/json', 'Content-Length: ' . strlen($data));
} |
That actually just sets the body to the string argument. http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOSTFIELDS
|
Just so it's clear: the upstream bug is about the request body. |
I know that terminus is making some non-vanilla requests, but I wonder if it would make sense (assuming it's possible) to use a higher level library like HTTP_Request2 or Requests that would use alternative strategies if curl isn't on the system... and make for cleaner more readable connection code.
The text was updated successfully, but these errors were encountered: