Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0e27208
Support multipart form POST requests.
bjeavons Jan 28, 2011
88938a0
Added get_request_options() to allow checking the options set in curl
hamstar Feb 19, 2011
293d5f3
default values
jrivero Mar 4, 2011
03fab04
Use exceptions for the error handling.
KendallHopkins Jun 21, 2011
3a0cc7d
Use a better and sorted list of exception.
KendallHopkins Jun 22, 2011
9f6d38e
Include error message in throw exception.
KendallHopkins Sep 2, 2011
786905d
Handle multiple response headers when following a redirection
Dec 20, 2011
3101030
Merge branch 'master' of https://github.com/bjeavons/curl
Dec 20, 2011
7327f41
Merge branch 'master' of https://github.com/hamstar/curl
Dec 20, 2011
b1593bb
Merge branch 'master' of https://github.com/SimpleUpdates/curl.git
Dec 20, 2011
9cefbb5
Fixed errors caused from the merge of https://github.com/SimpleUpdate…
Dec 20, 2011
67caeda
Added support for HTTP basic authentication
Dec 20, 2011
f70be61
Added ztest as submodule
Dec 21, 2011
5dc0822
Added debug support
aseba Mar 25, 2012
5962b52
added composer spec with the name shuber/curl
hamstar Jun 2, 2012
e6b1a12
Merge pull request #1 from hamstar/master
Jun 14, 2012
2283a0d
merge with hugo chinchilla
nickl- Jun 19, 2012
fc6eed1
huge refactoring: Use of getters|setters, PUT-Data-Requests
May 21, 2010
732f2bf
huge refactoring: Use of getters|setters, PUT-Data-Requests
May 21, 2010
accdb81
added missing require_once
May 21, 2010
d28f9ec
minor changes in curl & curl_response
Aug 17, 2010
7b358fc
Unit tests => PHPUNIT
Mar 1, 2011
2d3b276
added SSL handling
Mar 2, 2011
9231a7b
fix setOption() and setOptions()
apemsel Mar 22, 2011
e0bcb28
gitignore
Apr 8, 2011
500dbd7
includes
Apr 8, 2011
d77556e
small bugfix for urls without scheme
Apr 8, 2011
17b27f7
added very simple autoloader
Apr 12, 2011
f00a2dd
added very simple autoloader
Apr 12, 2011
cafc4ac
test changes
Apr 12, 2011
8dec78d
Merge forks fabeat/curl and hugochinchilla/curl
nickl- Jun 19, 2012
80f8d62
Merge with Sebastian Alvarez: aseba/curl
nickl- Jun 19, 2012
0b2ae29
Merge contrib branch 'merge-stream'
nickl- Jun 19, 2012
3596d92
Better Headers and optimizations.
nickl- Jun 19, 2012
4155d96
Merge with latest from professional-style
nickl- Jun 19, 2012
8595dbb
Restructure PSR-0 compliance, and reformatting.
nickl- Jun 20, 2012
8f2b106
Let the magic begin
nickl- Jun 20, 2012
cf551d3
The class file is now called Curl.php and not curl.php
nickl- Jun 20, 2012
e647ecd
Merge branch 'master' of git://github.com/jrivero/curl into merge-stream
nickl- Jun 20, 2012
f2e417f
merge changes from jrivero
nickl- Jun 20, 2012
d1974aa
Standard header values initialized
nickl- Jun 20, 2012
083552b
Resolve all removed references
nickl- Jun 20, 2012
2261fa3
PSR-1 and PSR-2 coding standard compliancy.
nickl- Jun 20, 2012
f29f392
manual kleen fix
nickl- Jun 20, 2012
b8965ff
more cs conformities
nickl- Jun 20, 2012
547be35
Add package descriptors
nickl- Jun 20, 2012
869d397
Added missing ref to Exception
nickl- Jul 3, 2012
1a7fefa
Added isJson convenience method
nickl- Jul 3, 2012
ab023a5
Anchor regex to allow headers with wildcard
mattleff Feb 19, 2015
611e24b
Correct exception class
mattleff Feb 25, 2015
f9a607f
Merge pull request #1 from SimpleUpdates/composer
mattleff Feb 25, 2015
3e021f6
Bump version
mattleff Feb 25, 2015
2f45c2e
Fix bugs; tag 1.0.2
mattleff Mar 5, 2015
44a19a8
1.0.3 with fix for unit tests
mattleff Mar 5, 2015
0df818d
Fixes issue with HTTP 100-Continue header
mattleff Mar 6, 2015
e4e1540
Update composer.json
mattleff Mar 6, 2015
2de5bd1
Only throw exception if there's an error
mattleff Apr 21, 2016
3d2f30e
Match all response headers until end of headers
mattleff Mar 5, 2018
98613f8
Remove Reason-Phrase
Apr 17, 2020
a15d7ec
Update cacert.pem
Apr 27, 2022
b1747aa
Update composer.json
Apr 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib/curl_cookie.txt
lib/curl_cookie.txt
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test/ztest"]
path = test/ztest
url = git://github.com/jaz303/ztest.git
6 changes: 3 additions & 3 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Copyright (c) 2008 Sean Huber - shuber@huberry.com

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down
25 changes: 12 additions & 13 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ Click the `download` link above or `git clone git://github.com/shuber/curl.git`

Simply require and initialize the `Curl` class like so:

require_once 'curl.php';
require_once 'autoload.php';
$curl = new Curl;


### Performing a Request

The Curl object supports 5 types of requests: HEAD, GET, POST, PUT, and DELETE. You must specify a url to request and optionally specify an associative array or string of variables to send along with it.
The Curl object supports 5 types of requests: HEAD, GET, POST, PUT, and DELETE. You must specify a url to request and optionally specify an associative array or string of variables to send along with it. The Curl object will append the array of $vars to the $url as a query string for all methods except POST.

$response = $curl->head($url, $vars = array());
$response = $curl->get($url, $vars = array()); # The Curl object will append the array of $vars to the $url as a query string
$response = $curl->get($url, $vars = array());
$response = $curl->post($url, $vars = array());
$response = $curl->put($url, $vars = array());
$response = $curl->put($url, $put_data, $vars = array());
$response = $curl->delete($url, $vars = array());

To use a custom request methods, you can call the `request` method:

$response = $curl->request('YOUR_CUSTOM_REQUEST_TYPE', $url, $vars = array());
$response = $curl->request('YOUR_CUSTOM_REQUEST_TYPE', $url, $vars = array(), $put_data = null);

All of the built in request methods like `put` and `get` simply wrap the `request` method. For example, the `post` method is implemented like:

Expand All @@ -44,7 +44,7 @@ Examples:

# The Curl object will append '&some_variable=some_value' to the url
$response = $curl->get('google.com?q=test', array('some_variable' => 'some_value'));

$response = $curl->post('test.com/posts', array('title' => 'Test', 'body' => 'This is a test'));

All requests return a CurlResponse object (see below) or false if an error occurred. You can access the error string with the `$curl->error()` method.
Expand Down Expand Up @@ -82,7 +82,7 @@ Which would display something like
[Server] => gws
[Connection] => close
)

The CurlResponse class defines the magic [__toString()](http://php.net/__toString) method which will return the response body, so `echo $response` is the same as `echo $response->body`


Expand All @@ -109,8 +109,8 @@ You may even set these headers manually if you wish (see below)

You can set custom headers to send with the request

$curl->headers['Host'] = 12.345.678.90;
$curl->headers['Some-Custom-Header'] = 'Some Custom Value';
$curl->setHeader('Host', 12.345.678.90);
$curl->setHeader('Some-Custom-Header', 'Some Custom Value');


### Setting Custom CURL request options
Expand All @@ -122,10 +122,9 @@ By default, the `Curl` object will follow redirects. You can disable this by set
You can set/override many different options for CURL requests (see the [curl_setopt documentation](http://php.net/curl_setopt) for a list of them)

# any of these will work
$curl->options['AUTOREFERER'] = true;
$curl->options['autoreferer'] = true;
$curl->options['CURLOPT_AUTOREFERER'] = true;
$curl->options['curlopt_autoreferer'] = true;
$curl->setOption('AUTOREFERER', true);
$curl->setOption('CURLOPT_AUTOREFERER', true);
$curl->setOption(CURLOPT_AUTOREFERER, true);


## Testing
Expand Down
21 changes: 21 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

function curl_autoload($className)
{
$prefix = dirname(__FILE__).DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR;
switch ($className)
{
case 'Curl':
require_once $prefix.'curl.php';
break;
case 'CurlResponse':
require_once $prefix.'curl_response.php';
break;
case 'CurlPutData':
require_once $prefix.'curl_put_data.php';
break;
}
}

spl_autoload_register('curl_autoload');

72 changes: 72 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "Shuber\/Curl",
"description": "A basic CURL wrapper for PHP (see [http:\/\/php.net\/curl](http:\/\/php.net\/curl) for more information about the libcurl extension for PHP)",
"version": "1.0.5",
"type": "library",
"time": "2015-03-06 9:06:37",
"homepage": "",
"license": "MIT",
"authors": [
{
"name": "Adrian Pemsel",
"email": "adrian@adrianpemsel.de"
},
{
"name": "Ben Jeavons",
"email": "benjamin.jeavons@colorado.edu"
},
{
"name": "Hugo Chinchilla Carbonell",
"email": "hugo@bulma.net"
},
{
"name": "Jordi Rivero",
"email": "jrivero24@yahoo.es"
},
{
"name": "Kendall Hopkins",
"email": "softwareelves@gmail.com"
},
{
"name": "Sean Huber",
"email": "shuber@huberry.com"
},
{
"name": "Sebastian M. Alvarez",
"email": "sebastianmalvarez@gmail.com"
},
{
"name": "Simone Carletti",
"email": "weppos@weppos.net"
},
{
"name": "fabeat",
"email": "fg@linkable.de"
},
{
"name": "ide user ide_hamstar",
"email": "hamstar@telescum.co.nz"
},
{
"name": "nickl-",
"email": "nick@jigsoft.co.za"
},
{
"name": "shuber",
"email": "sean.huber@cox.net"
},
{
"name": "Matthew Leffler",
"email": "matthew@simpleupdates.com"
},
{
"name": "Carl Brugger",
"email": "carl@simpleupdates.com"
}
],
"autoload": {
"psr-0": {
"Shuber\\Curl": "lib\/"
}
}
}
3 changes: 1 addition & 2 deletions curl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?php

require_once 'lib'.DIRECTORY_SEPARATOR.'curl.php';
require_once 'lib'.DIRECTORY_SEPARATOR.'curl_response.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'autoload.php';
Loading