Check-in [063d94349d]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add curl()->assert() to be run after ->exec() |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
063d94349d250a1aa4e237c71009215d |
User & Date: | mario 2014-08-13 16:09:20 |
Context
2014-08-13
| ||
16:09 | ::http filter was too strict (leading numbers in URLs) check-in: abc330bf7c user: mario tags: trunk | |
16:09 | Add curl()->assert() to be run after ->exec() check-in: 063d94349d user: mario tags: trunk | |
16:08 | Invalid autoupdate() invocation check-in: f8152d1c76 user: mario tags: trunk | |
Changes
Changes to lib/curl.php.
1 2 3 4 5 | <?php /** * api: php7 * title: fluent curl * description: simple wrapper around curl functions | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php /** * api: php7 * title: fluent curl * description: simple wrapper around curl functions * version: 0.3 * license: Public Domain * * * This simple wrapper class and its factory function allow * compact invocations of curl. You can pass either just an * URL, an option array, a previously wrapped curl() or a * raw curl resource handle. |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | static $defaults = array( "returntransfer" => 1, "httpget" => 1, "http200aliases" => array(200, 201, 202, 203), "header" => 0, ); /** * Initialize, where $params is usually just an $url, or an [OPT=>val] list * */ function __construct($params) { | > > > > > > > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | static $defaults = array( "returntransfer" => 1, "httpget" => 1, "http200aliases" => array(200, 201, 202, 203), "header" => 0, ); /** * Some checks before returning the resulting content. * */ public $assert = array(); /** * Initialize, where $params is usually just an $url, or an [OPT=>val] list * */ function __construct($params) { |
︙ | ︙ | |||
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | # neither exists else { trigger_error("curl: unknown '$opt' option", E_USER_ERROR); } return $this; } /** * retrieve constants * */ function __get($opt) { | > > > > > > > > > > > > > > > > > > > > > > > > > > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | # neither exists else { trigger_error("curl: unknown '$opt' option", E_USER_ERROR); } return $this; } /** * Append result-checks such as ["HTTP_CODE" => [200, 201]]. * */ function assert($list) { $this->assert += $list; return $this; } /** * Wrap exec() to test result handle for HTTP or CURL properties. * */ function exec() { $args = func_get_args(); $content = $this->__call("exec", $args); foreach ($this->assert as $option => $values) { if (!in_array($this->$option, $values)) { return NULL; } } return $content; } /** * retrieve constants * */ function __get($opt) { |
︙ | ︙ |