Added "protocol" option that allows changing of the HTTP protocol used for
authorIlia Alshanetsky <iliaa@php.net>
Fri, 6 Jan 2006 21:23:02 +0000 (21:23 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 6 Jan 2006 21:23:02 +0000 (21:23 +0000)
requests.
Do not try to send POST request components when making an OPTIONS request.

http_request_api.c
http_request_object.c

index 605b6becebc18c77dae3f9f19fcf31b0c25a5439..00f4b9d48d6fb7e1d28dc05b1a820efa72191605 100644 (file)
@@ -358,6 +358,7 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(IOCTLDATA, NULL);
                HTTP_CURL_OPT(READDATA, NULL);
                HTTP_CURL_OPT(INFILESIZE, 0);
+               HTTP_CURL_OPT(HTTP_VERSION, CURL_HTTP_VERSION_NONE);
        }
 }
 /* }}} */
@@ -534,6 +535,11 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
                HTTP_CURL_OPT(MAXFILESIZE, Z_LVAL_P(zoption));
        }
 
+       /* http protocol */
+       if ((zoption = http_request_option(request, options, "protocol", IS_LONG))) {
+               HTTP_CURL_OPT(HTTP_VERSION, Z_LVAL_P(zoption));
+       }
+
        /* lastmodified */
        if ((zoption = http_request_option(request, options, "lastmodified", IS_LONG))) {
                if (Z_LVAL_P(zoption)) {
@@ -623,7 +629,7 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        }
 
        /* attach request body */
-       if (request->body && (request->meth != HTTP_GET) && (request->meth != HTTP_HEAD)) {
+       if (request->body && (request->meth != HTTP_GET) && (request->meth != HTTP_HEAD) && (request->meth != HTTP_OPTIONS)) {
                switch (request->body->type)
                {
                        case HTTP_REQUEST_BODY_CSTRING:
index 7eb00d493809e176c1bce075413d84f364113529..5e233adabf44a62c6044d0af5c607b64eefd5e5a 100644 (file)
@@ -403,6 +403,11 @@ static inline void _http_request_object_declare_default_properties(TSRMLS_D)
        /* WebDAV Access Control - RFC 3744 */
        DCL_CONST(long, "METH_ACL", HTTP_ACL);
 
+       /* cURL HTTP protocol versions */
+       DCL_CONST(long, "VERSION_1_0", CURL_HTTP_VERSION_1_0);
+       DCL_CONST(long, "VERSION_1_1", CURL_HTTP_VERSION_1_1);
+       DCL_CONST(long, "VERSION_NONE", CURL_HTTP_VERSION_NONE);
+
        /*
         * Auth Constants
         */