switch (type) {
case CURLINFO_HEADER_IN:
case CURLINFO_DATA_IN:
- case CURLINFO_HEADER_OUT:
- case CURLINFO_DATA_OUT:
- php_http_buffer_append(h->buffer, data, length);
+ php_http_buffer_append(h->response.buffer, data, length);
if (curl->options.redirects) {
flags |= PHP_HTTP_MESSAGE_PARSER_EMPTY_REDIRECTS;
}
- if (PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE == php_http_message_parser_parse(h->parser, h->buffer, flags, &h->message)) {
+ if (PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE == php_http_message_parser_parse(h->response.parser, h->response.buffer, flags, &h->response.message)) {
+ return -1;
+ }
+ break;
+
+ case CURLINFO_HEADER_OUT:
+ case CURLINFO_DATA_OUT:
+ php_http_buffer_append(h->request.buffer, data, length);
+
+ if (PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE == php_http_message_parser_parse(h->request.parser, h->request.buffer, flags, &h->request.message)) {
return -1;
}
break;
if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("connecttimeout"), IS_DOUBLE))) {
curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT_MS, (long)(Z_DVAL_P(zoption)*1000));
}
+
+#if PHP_HTTP_CURL_VERSION(7,25,0)
+ /* tcp */
+ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("tcp_keepalive"), IS_BOOL))) {
+ curl_easy_setopt(ch, CURLOPT_TCP_KEEPALIVE, (long)Z_BVAL_P(zoption));
+ }
+ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("tcp_keepidle"), IS_LONG))) {
+ curl_easy_setopt(ch, CURLOPT_TCP_KEEPIDLE, Z_LVAL_P(zoption));
+ }
+ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("tcp_keepintvl"), IS_LONG))) {
+ curl_easy_setopt(ch, CURLOPT_TCP_KEEPINTVL, Z_LVAL_P(zoption));
+ }
+#endif
/* ssl */
if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("ssl"), IS_ARRAY))) {
curl_easy_setopt(ch, CURLOPT_TIMECONDITION, 0L);
curl_easy_setopt(ch, CURLOPT_TIMEVALUE, 0L);
curl_easy_setopt(ch, CURLOPT_TIMEOUT, 0L);
- curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 3);
+ curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 3L);
+#if PHP_HTTP_CURL_VERSION(7,25,0)
+ curl_easy_setopt(ch, CURLOPT_TCP_KEEPALIVE, 0L);
+ curl_easy_setopt(ch, CURLOPT_TCP_KEEPIDLE, 60L);
+ curl_easy_setopt(ch, CURLOPT_TCP_KEEPINTVL, 60L);
+#endif
curl_easy_setopt(ch, CURLOPT_SSLCERT, NULL);
curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, NULL);
curl_easy_setopt(ch, CURLOPT_SSLCERTPASSWD, NULL);
}
/* request headers */
+ php_http_message_update_headers(msg);
if (zend_hash_num_elements(&msg->hdrs)) {
php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0);
zval **header_val;
#define PHP_HTTP_CURL_CLIENT_ME(method, visibility) PHP_ME(HttpClientCURL, method, PHP_HTTP_ARGS(HttpClientCURL, method), visibility)
#define PHP_HTTP_CURL_CLIENT_CLIENT_MALIAS(me, vis) ZEND_FENTRY(me, ZEND_MN(HttpClient_##me), PHP_HTTP_ARGS(HttpClientCURL, me), vis)
-PHP_HTTP_BEGIN_ARGS(send, 1)
+PHP_HTTP_BEGIN_ARGS(send, 0)
PHP_HTTP_ARG_VAL(request, 0)
PHP_HTTP_END_ARGS;