+ if (return_value_used) {
+ RETURN_PROP(options);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setSslOptions([array options])
+ *
+ * Set SSL options.
+ *
+ * Accepts an associative array as parameter containing any SSL specific options.
+ * If the parameter is empty or omitted, the SSL options will be reset.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, setSslOptions)
+{
+ http_request_object_set_options_subr("ssl", 1, 0);
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::addSslOptions(array options)
+ *
+ * Set additional SSL options.
+ *
+ * Expects an associative array as parameter containing additional SSL specific options.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, addSslOptions)
+{
+ http_request_object_set_options_subr("ssl", 0, 0);
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getSslOtpions()
+ *
+ * Get previously set SSL options.
+ *
+ * Returns an associative array containing any previously set SSL options.
+ */
+PHP_METHOD(HttpRequest, getSslOptions)
+{
+ http_request_object_get_options_subr("ssl");
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::addHeaders(array headers)
+ *
+ * Add request header name/value pairs.
+ *
+ * Expects an associative array as parameter containing additional header
+ * name/value pairs.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, addHeaders)
+{
+ http_request_object_set_options_subr("headers", 0, 1);
+}
+
+/* {{{ proto bool HttpRequest::setHeaders([array headers])
+ *
+ * Set request header name/value pairs.
+ *
+ * Accepts an associative array as parameter containing header name/value pairs.
+ * If the parameter is empty or omitted, all previously set headers will be unset.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, setHeaders)
+{
+ http_request_object_set_options_subr("headers", 1, 1);
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getHeaders()
+ *
+ * Get previously set request headers.
+ *
+ * Returns an associative array containing all currently set headers.
+ */
+PHP_METHOD(HttpRequest, getHeaders)
+{
+ http_request_object_get_options_subr("headers");
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setCookies([array cookies])
+ *
+ * Set cookies.
+ *
+ * Accepts an associative array as parameter containing cookie name/value pairs.
+ * If the parameter is empty or omitted, all previously set cookies will be unset.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, setCookies)
+{
+ http_request_object_set_options_subr("cookies", 1, 0);
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::addCookies(array cookies)
+ *
+ * Add cookies.
+ *
+ * Expects an associative array as parameter containing any cookie name/value
+ * pairs to add.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, addCookies)
+{
+ http_request_object_set_options_subr("cookies", 0, 0);
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getCookies()
+ *
+ * Get previously set cookies.
+ *
+ * Returns an associative array containing any previously set cookies.
+ */
+PHP_METHOD(HttpRequest, getCookies)
+{
+ http_request_object_get_options_subr("cookies");
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::enableCookies()
+ *
+ * Enable automatic sending of received cookies.
+ * Note that cuutomly set cookies will be sent anyway.
+ */
+PHP_METHOD(HttpRequest, enableCookies)
+{
+ NO_ARGS {
+ getObject(http_request_object, obj);
+ RETURN_SUCCESS(http_request_enable_cookies(obj->request));
+ }
+
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::resetCookies([bool session_only = FALSE])
+ *
+ * Reset all automatically received/sent cookies.
+ * Note that customly set cookies are not affected.
+ *
+ * Accepts an optional bool parameter specifying
+ * whether only session cookies should be reset
+ * (needs libcurl >= v7.15.4, else libcurl >= v7.14.1).
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, resetCookies)
+{
+ zend_bool session_only = 0;
+ getObject(http_request_object, obj);
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &session_only)) {
+ RETURN_FALSE;
+ }
+ RETURN_SUCCESS(http_request_reset_cookies(obj->request, session_only));
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setUrl(string url)
+ *
+ * Set the request URL.
+ *
+ * Expects a string as parameter specifying the request url.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, setUrl)
+{
+ char *URL = NULL;
+ int URL_len;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &URL, &URL_len)) {
+ RETURN_FALSE;
+ }
+
+ UPD_STRL(url, URL, URL_len);
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto string HttpRequest::getUrl()
+ *
+ * Get the previously set request URL.
+ *
+ * Returns the currently set request url as string.
+ */
+PHP_METHOD(HttpRequest, getUrl)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ RETURN_PROP(url);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setMethod(int request_method)
+ *
+ * Set the request method.
+ *
+ * Expects an int as parameter specifying the request method to use.
+ * In PHP 5.1+ HttpRequest::METH_*, otherwise the HTTP_METH_* constants can be used.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, setMethod)
+{
+ long meth;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &meth)) {
+ RETURN_FALSE;
+ }
+
+ UPD_PROP(long, method, meth);
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int HttpRequest::getMethod()
+ *
+ * Get the previously set request method.
+ *
+ * Returns the currently set request method.
+ */
+PHP_METHOD(HttpRequest, getMethod)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ RETURN_PROP(method);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setContentType(string content_type)
+ *
+ * Set the content type the post request should have.
+ *
+ * Expects a string as parameters containing the content type of the request
+ * (primary/secondary).
+ *
+ * Returns TRUE on success, or FALSE if the content type does not seem to
+ * contain a primary and a secondary part.
+ */
+PHP_METHOD(HttpRequest, setContentType)
+{
+ char *ctype;
+ int ct_len;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ctype, &ct_len)) {
+ RETURN_FALSE;
+ }
+
+ if (ct_len) {
+ HTTP_CHECK_CONTENT_TYPE(ctype, RETURN_FALSE);
+ }
+ UPD_STRL(contentType, ctype, ct_len);
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto string HttpRequest::getContentType()
+ *
+ * Get the previously content type.
+ *
+ * Returns the previously set content type as string.
+ */
+PHP_METHOD(HttpRequest, getContentType)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ RETURN_PROP(contentType);
+ }
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setQueryData([mixed query_data])
+ *
+ * Set the URL query parameters to use, overwriting previously set query parameters.
+ * Affects any request types.
+ *
+ * Accepts a string or associative array parameter containing the pre-encoded
+ * query string or to be encoded query fields. If the parameter is empty or
+ * omitted, the query data will be unset.
+ *
+ * Returns TRUE on success, or FALSE on failure.
+ */
+PHP_METHOD(HttpRequest, setQueryData)
+{
+ zval *qdata = NULL;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!", &qdata)) {
+ RETURN_FALSE;
+ }
+
+ if ((!qdata) || Z_TYPE_P(qdata) == IS_NULL) {
+ UPD_STRL(queryData, "", 0);
+ } else if ((Z_TYPE_P(qdata) == IS_ARRAY) || (Z_TYPE_P(qdata) == IS_OBJECT)) {
+ char *query_data = NULL;
+
+ if (SUCCESS != http_urlencode_hash(HASH_OF(qdata), &query_data)) {
+ RETURN_FALSE;
+ }
+
+ UPD_PROP(string, queryData, query_data);
+ efree(query_data);
+ } else {
+ zval *orig = qdata;
+
+ convert_to_string_ex(&qdata);
+ UPD_STRL(queryData, Z_STRVAL_P(qdata), Z_STRLEN_P(qdata));
+ if (orig != qdata) {
+ zval_ptr_dtor(&qdata);