Commit Graph
46 Commits
Author SHA1 Message Date
Grischa Brockhaus 655607d739 parse_url does not return port as array, but it is used as array in Request.php
So I added a check, wether this is an array actually, else I use the port as intended as int. I would assume, that that array check is needless altogether but maybe old PHP versions needed that?
2021-06-02 13:41:15 +02:00
thenetexpertsandAhmad Nassri 14aa9aa691 feat(HEAD): CURLOPT_NOBODY option for HEAD requests
* When using HEAD requests set the appropriate curl header to not wait for a response body. See http://www.php.net/manual/en/function.curl-setopt.php on CURLOPT_NOBODY.

* Add simple test for HEAD request.
2017-02-24 09:06:01 -08:00
İrfan EvrensandAhmad Nassri 5d304c6f6c improved syntax and some codes. (#108)
* improved syntax and some codes.

* back to original for Body.php
2016-05-31 12:59:14 -04:00
Jesse Skrivseth a3446f6d99 Update Request.php
Remove curl_setopt(self::$handle, CURLOPT_POSTREDIR, 3);  in favor of the caller being well-behaved and setting this option as needed
2016-04-19 23:05:11 -06:00
Jesse Skrivseth e9ea4dbee2 Don't use CURLOPT_CUSTOMREQUEST for POSTs
I think the current usage of CURLOPT_CUSTOMREQUEST is wrong. As far as I can tell CURLOPT_CUSTOMREQUEST = Method::POST is not the same thing as CURLOPT_POST = true. 

I struggled for hours with POSTed data not being accepted by IIS. First IIS threw an HTTP 411 due to curl not sending a Content-Length header. That is solved by replacing CURLOPT_CUSTOMREQUEST with CURLOPT_POST in the case of actual POSTs. Also, IIS in my case returns an HTTP 301 redirect, which I need Unirest to follow, so I set the CURLOPT_POSTREDIR = 3 in order to let the POST follow on redirect via 301 or 302. 

Notice this: https://curl.haxx.se/libcurl/c/CURLOPT_CUSTOMREQUEST.html - "Many people have wrongly used this option to replace the entire request with their own, including multiple headers and POST contents. While that might work in many cases, it will cause libcurl to send invalid requests and it could possibly confuse the remote server badly. Use CURLOPT_POST and CURLOPT_POSTFIELDS to set POST data. Use CURLOPT_HTTPHEADER to replace or extend the set of headers sent by libcurl. Use CURLOPT_HTTP_VERSION to change HTTP version."

In any case, I know that the CURLOPT_POSTREDIR option probably shouldn't go here and should be client configurable, but I can't find a good place for it. It would be nice to have one-shot $curlOpts passed in with the send method, or curlOpts() that otherwise live for only one curl_exec().
2016-04-19 22:49:27 -06:00
Kairat Jenishev 2d0cd4c8d9 Typofix 2016-04-14 17:01:32 +06:00
Igor Rusinov 28080c975c Fixedissue with priority of headers 2016-03-20 20:53:52 +03:00
Ahmad Nassri b6328f270f chore(travis): fix namespacing issues 2016-02-24 23:23:54 -05:00
Ahmad Nassri 825cee7dc7 chore(travis): fix namespacing issues 2016-02-24 23:12:45 -05:00
Ahmad Nassri d23cdc5593 refactor(request): request body management is now externalized to helper methods 2016-02-24 23:01:21 -05:00
Ahmad Nassri 0f3a22d63e feat(json): json pecl extension may be available all the time 2016-02-24 22:07:25 -05:00
Tomasz Sawicki d950a88257 Fix creating CURLFile 2016-02-16 19:54:45 +01:00
Tomasz Sawicki d0fc831a00 Fix PHPDoc 2016-02-16 10:49:00 +01:00
Igor Rusinov ca6a3b1daf Fixed setting of default headers array 2016-01-18 23:24:14 +03:00
frankdee be5ee63ad1 shortened cURL options array merging 2015-12-14 19:17:31 +01:00
frankdee 32334a6bfa improved solution to override cURL options, that preserves the right indices in cURL option arrays
(Note: PHP seems to not override all options when calling 'curl_setopt_array(..)' several times after another)
2015-12-14 13:55:49 +01:00
Ahmad Nassri a3312a0ecd allow to override curlopts 2015-12-11 18:38:09 -05:00
Gabriel 2b5b349036 phpdoc return type for ::post 2015-07-27 22:07:05 +03:00
Jesse Skrivseth f257217434 Fix CURLOPT_SSL_VERIFYHOST issue
libcurl's CURLOPT_SSL_VERIFYHOST option accepts only values 0 and 2. This fix is fail-secure in that SSL host verification will be enabled regardless of what a caller passes to Request::verifyHost($bool) unless $bool === false.
2015-06-08 08:50:58 -06:00
Jesse Skrivseth c9c0a85250 Allow disabling of CURLOPT_SSL_VERIFYHOST
Useful when the SSL cert has an invalid or non-resolvable hostname
2015-06-05 19:50:11 -06:00
Ahmad Nassri 4221ee5138 setting custom curl options
- `Unirest\Request::curlOpt()`
- `Unirest\Request::curlOpts()`
- `Unirest\Request::clearCurlOpts()`

fixes #78
2015-04-08 17:35:14 -04:00
cristianp6 0293eb258c Add cookie string support, aka CURLOPT_COOKIE 2015-04-03 12:04:49 +02:00
cristianp6 a1ed45be55 Fixed "Notice: Undefined variable: ch" on curl_setopt cookieFile 2015-04-03 11:16:17 +02:00
Ahmad Nassri 8da79e7898 updating README and fixing typo 2015-04-02 14:22:32 -04:00
Ahmad Nassri 217b436124 manually applying PR by @daydiff due to complex merge issues, closes #67 2015-04-02 14:11:23 -04:00
Ahmad Nassri 530905c7c9 switch to using curl_setopt_array for better readability, added utility methods Fixes #66 2015-03-01 02:48:16 -05:00
thibaultCha 8b47e051ba Set Mashape Key by calling setDefaultHeader 2015-02-05 23:02:12 -08:00
thibaultCha fb241f6898 Native 'setMashapeKey' method for X-Mashape-Key header 2015-02-05 20:49:06 -08:00
Ahmad Nassri d5a7ad40bd fix to deprecated method + more tests 2015-02-05 13:00:49 -05:00
Ahmad Nassri 8af870ff69 fix depreicated method as well! 2015-02-05 12:53:30 -05:00
Ahmad Nassri ae01978eb3 php 5.4 cURL does not support setting username and password separately 2015-02-05 12:48:56 -05:00
Ahmad Nassri 2074abf904 keeping deprecated auth method functional 2015-02-05 12:22:46 -05:00
Ahmad Nassri 96cdf61101 allowing all native libcurl authentication methods 2015-02-05 12:19:47 -05:00
Ahmad Nassri c5be546d1b Proxies!
closes #47
2015-02-05 11:33:59 -05:00
Ahmad Nassri 3591292c3e eliminating code smells and converting Unirest\Request::send into a public method 2015-01-15 01:42:43 -05:00
Ahmad Nassri ba25e0304a JSON Decoding options
- users can now specify all the json_decode params to be used
- additional method added: `Unirest\Request::defaultHeaders`
2015-01-15 01:22:23 -05:00
Ahmad Nassri be9bca1d5a splitting out Unirest\File and updating README 2015-01-14 18:31:21 -05:00
Ahmad Nassri ed2a2df982 updating Request utility methods to match all of RFC7231 2015-01-14 18:15:13 -05:00
Ahmad Nassri 7a6df4cb82 adding the full scope of the HTTP Methods registery 2015-01-14 18:07:10 -05:00
Ahmad Nassri eccbc76469 improving curl post body flattening for multidimensional arrays 2014-12-18 01:16:40 -05:00
Ahmad Nassri d004129842 more scrutinizer-ci 2014-12-18 00:08:12 -05:00
Ahmad Nassri 97f51e1269 fixes from scrutinizer-ci 2014-12-18 00:05:49 -05:00
Ahmad Nassri 8ee4ba0753 adding a better query string parser that can handle arrays 2014-12-17 23:57:06 -05:00
Ahmad Nassri 07aa7ab19f removing redundant setter/getter + adding PECL_HTTP like header parsing 2014-12-17 23:03:20 -05:00
Ahmad Nassri b6efa7e1cc PSR compliance 2014-12-17 22:44:33 -05:00
Ahmad Nassri 6347fa33ee modifying directory name to standard usage 2014-12-17 22:38:46 -05:00