projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- #ifdef CURLOPT_COOKIELIST out for libcurl < v7.14.1
[m6w6/ext-http]
/
http_request_api.c
diff --git
a/http_request_api.c
b/http_request_api.c
index 41801656e82849fad99c28d5c2bca5a24ee05be0..96a613fd66a1a1fb5e95e10d7d21c27bcac7da36 100644
(file)
--- a/
http_request_api.c
+++ b/
http_request_api.c
@@
-130,7
+130,7
@@
PHP_MINIT_FUNCTION(http_request)
CRYPTO_set_id_callback(http_openssl_thread_id);
CRYPTO_set_locking_callback(http_openssl_thread_lock);
#endif
CRYPTO_set_id_callback(http_openssl_thread_id);
CRYPTO_set_locking_callback(http_openssl_thread_lock);
#endif
-#ifdef HTTP_NED_GNUTLS_TSL
+#ifdef HTTP_NE
E
D_GNUTLS_TSL
gcry_control(GCRYCTL_SET_THREAD_CBS, &http_gnutls_tsl);
#endif
gcry_control(GCRYCTL_SET_THREAD_CBS, &http_gnutls_tsl);
#endif
@@
-257,7
+257,7
@@
PHP_MSHUTDOWN_FUNCTION(http_request)
}
#define HTTP_CURL_OPT_STRING_EX(keyname, optname, obdc) \
if (!strcasecmp(key, keyname)) { \
}
#define HTTP_CURL_OPT_STRING_EX(keyname, optname, obdc) \
if (!strcasecmp(key, keyname)) { \
- zval *copy = http_request_option_cache
(request, keyname
, zval_copy(IS_STRING, *param)); \
+ zval *copy = http_request_option_cache
_ex(request, keyname, strlen(keyname)+1, 0
, zval_copy(IS_STRING, *param)); \
if (obdc) { \
HTTP_CHECK_OPEN_BASEDIR(Z_STRVAL_P(copy), return FAILURE); \
} \
if (obdc) { \
HTTP_CHECK_OPEN_BASEDIR(Z_STRVAL_P(copy), return FAILURE); \
} \
@@
-272,9
+272,10
@@
PHP_MSHUTDOWN_FUNCTION(http_request)
}
#define HTTP_CURL_OPT_LONG_EX(keyname, optname) \
if (!strcasecmp(key, keyname)) { \
}
#define HTTP_CURL_OPT_LONG_EX(keyname, optname) \
if (!strcasecmp(key, keyname)) { \
- zval *copy =
http_request_option_cache(request, keyname, zval_copy(IS_LONG, *param)
); \
+ zval *copy =
zval_copy(IS_LONG, *param
); \
HTTP_CURL_OPT(optname, Z_LVAL_P(copy)); \
key = NULL; \
HTTP_CURL_OPT(optname, Z_LVAL_P(copy)); \
key = NULL; \
+ zval_free(©); \
continue; \
}
/* }}} */
continue; \
}
/* }}} */
@@
-373,8
+374,6
@@
PHP_HTTP_API http_request *_http_request_init_ex(http_request *request, CURL *ch
/* {{{ void http_request_dtor(http_request *) */
PHP_HTTP_API void _http_request_dtor(http_request *request)
{
/* {{{ void http_request_dtor(http_request *) */
PHP_HTTP_API void _http_request_dtor(http_request *request)
{
- TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
-
http_curl_free(&request->ch);
http_request_reset(request);
http_curl_free(&request->ch);
http_request_reset(request);
@@
-451,8
+450,6
@@
PHP_HTTP_API void _http_request_defaults(http_request *request)
#if HTTP_CURL_VERSION(7,14,1)
HTTP_CURL_OPT(CURLOPT_COOKIELIST, NULL);
#endif
#if HTTP_CURL_VERSION(7,14,1)
HTTP_CURL_OPT(CURLOPT_COOKIELIST, NULL);
#endif
- HTTP_CURL_OPT(CURLOPT_COOKIEFILE, NULL);
- HTTP_CURL_OPT(CURLOPT_COOKIEJAR, NULL);
HTTP_CURL_OPT(CURLOPT_RANGE, NULL);
HTTP_CURL_OPT(CURLOPT_RESUME_FROM, 0);
HTTP_CURL_OPT(CURLOPT_MAXFILESIZE, 0);
HTTP_CURL_OPT(CURLOPT_RANGE, NULL);
HTTP_CURL_OPT(CURLOPT_RESUME_FROM, 0);
HTTP_CURL_OPT(CURLOPT_MAXFILESIZE, 0);
@@
-493,8
+490,6
@@
PHP_HTTP_API void _http_request_defaults(http_request *request)
PHP_HTTP_API void _http_request_set_progress_callback(http_request *request, zval *cb)
{
PHP_HTTP_API void _http_request_set_progress_callback(http_request *request, zval *cb)
{
- TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
-
if (request->_progress_callback) {
zval_ptr_dtor(&request->_progress_callback);
}
if (request->_progress_callback) {
zval_ptr_dtor(&request->_progress_callback);
}
@@
-760,27
+755,22
@@
PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
}
}
}
}
-#if HTTP_CURL_VERSION(7,14,1)
- /* reset cookies */
- if ((zoption = http_request_option(request, options, "resetcookies", IS_BOOL)) && Z_LVAL_P(zoption)) {
- HTTP_CURL_OPT(CURLOPT_COOKIELIST, "ALL");
- }
-#endif
-
/* session cookies */
if ((zoption = http_request_option(request, options, "cookiesession", IS_BOOL))) {
/* session cookies */
if ((zoption = http_request_option(request, options, "cookiesession", IS_BOOL))) {
- if (Z_
L
VAL_P(zoption)) {
+ if (Z_
B
VAL_P(zoption)) {
/* accept cookies for this session */
HTTP_CURL_OPT(CURLOPT_COOKIEFILE, "");
} else {
/* accept cookies for this session */
HTTP_CURL_OPT(CURLOPT_COOKIEFILE, "");
} else {
- /*
reset session cookies
*/
+ /*
don't load session cookies from cookiestore
*/
HTTP_CURL_OPT(CURLOPT_COOKIESESSION, 1);
}
}
/* cookiestore, read initial cookies from that file and store cookies back into that file */
HTTP_CURL_OPT(CURLOPT_COOKIESESSION, 1);
}
}
/* cookiestore, read initial cookies from that file and store cookies back into that file */
- if ((zoption = http_request_option(request, options, "cookiestore", IS_STRING)) && Z_STRLEN_P(zoption)) {
- HTTP_CHECK_OPEN_BASEDIR(Z_STRVAL_P(zoption), return FAILURE);
+ if ((zoption = http_request_option(request, options, "cookiestore", IS_STRING))) {
+ if (Z_STRLEN_P(zoption)) {
+ HTTP_CHECK_OPEN_BASEDIR(Z_STRVAL_P(zoption), return FAILURE);
+ }
HTTP_CURL_OPT(CURLOPT_COOKIEFILE, Z_STRVAL_P(zoption));
HTTP_CURL_OPT(CURLOPT_COOKIEJAR, Z_STRVAL_P(zoption));
}
HTTP_CURL_OPT(CURLOPT_COOKIEFILE, Z_STRVAL_P(zoption));
HTTP_CURL_OPT(CURLOPT_COOKIEJAR, Z_STRVAL_P(zoption));
}
@@
-841,23
+831,22
@@
PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
}
/* request method */
}
/* request method */
- switch (request->meth)
- {
+ switch (request->meth) {
case HTTP_GET:
HTTP_CURL_OPT(CURLOPT_HTTPGET, 1);
case HTTP_GET:
HTTP_CURL_OPT(CURLOPT_HTTPGET, 1);
- break;
+
break;
case HTTP_HEAD:
HTTP_CURL_OPT(CURLOPT_NOBODY, 1);
case HTTP_HEAD:
HTTP_CURL_OPT(CURLOPT_NOBODY, 1);
- break;
+
break;
case HTTP_POST:
HTTP_CURL_OPT(CURLOPT_POST, 1);
case HTTP_POST:
HTTP_CURL_OPT(CURLOPT_POST, 1);
- break;
+
break;
case HTTP_PUT:
HTTP_CURL_OPT(CURLOPT_UPLOAD, 1);
case HTTP_PUT:
HTTP_CURL_OPT(CURLOPT_UPLOAD, 1);
- break;
+
break;
default:
if (http_request_method_exists(0, request->meth, NULL)) {
default:
if (http_request_method_exists(0, request->meth, NULL)) {
@@
-866,20
+855,19
@@
PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", request->meth, request->url);
return FAILURE;
}
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", request->meth, request->url);
return FAILURE;
}
- break;
+
break;
}
/* attach request body */
if (request->body && (request->meth != HTTP_GET) && (request->meth != HTTP_HEAD) && (request->meth != HTTP_OPTIONS)) {
}
/* attach request body */
if (request->body && (request->meth != HTTP_GET) && (request->meth != HTTP_HEAD) && (request->meth != HTTP_OPTIONS)) {
- switch (request->body->type)
- {
+ switch (request->body->type) {
case HTTP_REQUEST_BODY_EMPTY:
/* nothing */
case HTTP_REQUEST_BODY_EMPTY:
/* nothing */
- break;
+
break;
case HTTP_REQUEST_BODY_CURLPOST:
HTTP_CURL_OPT(CURLOPT_HTTPPOST, (struct curl_httppost *) request->body->data);
case HTTP_REQUEST_BODY_CURLPOST:
HTTP_CURL_OPT(CURLOPT_HTTPPOST, (struct curl_httppost *) request->body->data);
- break;
+
break;
case HTTP_REQUEST_BODY_CSTRING:
if (request->meth != HTTP_PUT) {
case HTTP_REQUEST_BODY_CSTRING:
if (request->meth != HTTP_PUT) {
@@
-892,13
+880,12
@@
PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
HTTP_CURL_OPT(CURLOPT_IOCTLDATA, request);
HTTP_CURL_OPT(CURLOPT_READDATA, request);
HTTP_CURL_OPT(CURLOPT_INFILESIZE, request->body->size);
HTTP_CURL_OPT(CURLOPT_IOCTLDATA, request);
HTTP_CURL_OPT(CURLOPT_READDATA, request);
HTTP_CURL_OPT(CURLOPT_INFILESIZE, request->body->size);
- break;
+
break;
default:
/* shouldn't ever happen */
http_error_ex(HE_ERROR, 0, "Unknown request body type: %d (%s)", request->body->type, request->url);
return FAILURE;
default:
/* shouldn't ever happen */
http_error_ex(HE_ERROR, 0, "Unknown request body type: %d (%s)", request->body->type, request->url);
return FAILURE;
- break;
}
}
}
}
@@
-964,8
+951,7
@@
static size_t http_curl_read_callback(void *data, size_t len, size_t n, void *ct
TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
if (request->body) {
TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
if (request->body) {
- switch (request->body->type)
- {
+ switch (request->body->type) {
case HTTP_REQUEST_BODY_CSTRING:
{
size_t out = MIN(len * n, request->body->size - request->body->priv);
case HTTP_REQUEST_BODY_CSTRING:
{
size_t out = MIN(len * n, request->body->size - request->body->priv);
@@
-975,12
+961,11
@@
static size_t http_curl_read_callback(void *data, size_t len, size_t n, void *ct
request->body->priv += out;
return out;
}
request->body->priv += out;
return out;
}
+ break;
}
}
- break;
case HTTP_REQUEST_BODY_UPLOADFILE:
return php_stream_read((php_stream *) request->body->data, data, len * n);
case HTTP_REQUEST_BODY_UPLOADFILE:
return php_stream_read((php_stream *) request->body->data, data, len * n);
- break;
}
}
return 0;
}
}
return 0;
@@
-1026,18
+1011,17
@@
static curlioerr http_curl_ioctl_callback(CURL *ch, curliocmd cmd, void *ctx)
}
if (request->body) {
}
if (request->body) {
- switch (request->body->type)
- {
+ switch (request->body->type) {
case HTTP_REQUEST_BODY_CSTRING:
request->body->priv = 0;
return CURLIOE_OK;
case HTTP_REQUEST_BODY_CSTRING:
request->body->priv = 0;
return CURLIOE_OK;
- break;
+
break;
case HTTP_REQUEST_BODY_UPLOADFILE:
if (SUCCESS == php_stream_rewind((php_stream *) request->body->data)) {
return CURLIOE_OK;
}
case HTTP_REQUEST_BODY_UPLOADFILE:
if (SUCCESS == php_stream_rewind((php_stream *) request->body->data)) {
return CURLIOE_OK;
}
- break;
+
break;
}
}
}
}
@@
-1050,22
+1034,21
@@
static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size
{
http_request *request = (http_request *) ctx;
{
http_request *request = (http_request *) ctx;
- switch (type)
- {
+ switch (type) {
case CURLINFO_DATA_IN:
if (request->conv.last_type == CURLINFO_HEADER_IN) {
phpstr_appends(&request->conv.response, HTTP_CRLF);
}
case CURLINFO_HEADER_IN:
phpstr_append(&request->conv.response, data, length);
case CURLINFO_DATA_IN:
if (request->conv.last_type == CURLINFO_HEADER_IN) {
phpstr_appends(&request->conv.response, HTTP_CRLF);
}
case CURLINFO_HEADER_IN:
phpstr_append(&request->conv.response, data, length);
- break;
+
break;
case CURLINFO_DATA_OUT:
if (request->conv.last_type == CURLINFO_HEADER_OUT) {
phpstr_appends(&request->conv.request, HTTP_CRLF);
}
case CURLINFO_HEADER_OUT:
phpstr_append(&request->conv.request, data, length);
case CURLINFO_DATA_OUT:
if (request->conv.last_type == CURLINFO_HEADER_OUT) {
phpstr_appends(&request->conv.request, HTTP_CRLF);
}
case CURLINFO_HEADER_OUT:
phpstr_append(&request->conv.request, data, length);
- break;
+
break;
default:
#if 0
fprintf(stderr, "## ", type);
default:
#if 0
fprintf(stderr, "## ", type);
@@
-1085,7
+1068,7
@@
static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size
fprintf(stderr, "\n");
}
#endif
fprintf(stderr, "\n");
}
#endif
- break;
+
break;
}
if (type) {
}
if (type) {