+/* {{{ proto string HttpRequest::getPutData()
+ *
+ * Get previously set PUT data.
+ *
+ * Returns a string containing the currently set raw post data.
+ */
+PHP_METHOD(HttpRequest, getPutData)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ RETURN_PROP(putData);
+ }
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getResponseData()
+ *
+ * Get all response data after the request has been sent.
+ *
+ * Returns an associative array with the key "headers" containing an associative
+ * array holding all response headers, as well as the key "body" containing a
+ * string with the response body.
+ *
+ * If redirects were allowed and several responses were received, the data
+ * references the last received response.
+ */
+PHP_METHOD(HttpRequest, getResponseData)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ char *body;
+ size_t body_len;
+ zval *headers, *message = GET_PROP(responseMessage);
+
+ if (Z_TYPE_P(message) == IS_OBJECT) {
+ getObjectEx(http_message_object, msg, message);
+
+ array_init(return_value);
+
+ MAKE_STD_ZVAL(headers);
+ array_init(headers);
+ zend_hash_copy(Z_ARRVAL_P(headers), &msg->message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+ add_assoc_zval(return_value, "headers", headers);
+
+ phpstr_data(PHPSTR(msg->message), &body, &body_len);
+ add_assoc_stringl(return_value, "body", body, body_len, 0);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto mixed HttpRequest::getResponseHeader([string name])
+ *
+ * Get response header(s) after the request has been sent.
+ *
+ * Accepts an string as optional parameter specifying a certain header to read.
+ * If the parameter is empty or omitted all response headers will be returned.
+ *
+ * Returns either a string with the value of the header matching name if requested,
+ * FALSE on failure, or an associative array containing all response headers.
+ *
+ * If redirects were allowed and several responses were received, the data
+ * references the last received response.
+ */
+PHP_METHOD(HttpRequest, getResponseHeader)
+{
+ if (return_value_used) {
+ zval *header;
+ char *header_name = NULL;
+ int header_len = 0;
+
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &header_name, &header_len)) {
+ zval *message = GET_PROP(responseMessage);
+
+ if (Z_TYPE_P(message) == IS_OBJECT) {
+ getObjectEx(http_message_object, msg, message);
+
+ if (header_len) {
+ if ((header = http_message_header_ex(msg->message, pretty_key(header_name, header_len, 1, 1), header_len + 1))) {
+ RETURN_ZVAL(header, 1, 0);
+ }
+ } else {
+ array_init(return_value);
+ zend_hash_copy(Z_ARRVAL_P(return_value), &msg->message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+ return;
+ }
+ }
+ }
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getResponseCookies([int flags[, array allowed_extras]])
+ *
+ * Get response cookie(s) after the request has been sent.
+ *
+ * Returns an array of stdClass objects like http_parse_cookie would return.
+ *
+ * If redirects were allowed and several responses were received, the data
+ * references the last received response.
+ */
+PHP_METHOD(HttpRequest, getResponseCookies)
+{
+ if (return_value_used) {
+ long flags = 0;
+ zval *allowed_extras_array = NULL;
+
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|la", &flags, &allowed_extras_array)) {
+ int i = 0;
+ ulong idx = 0;
+ char *key = NULL, **allowed_extras = NULL;
+ zval **header = NULL, **entry = NULL, *message = GET_PROP(responseMessage);
+ HashPosition pos, pos1, pos2;
+
+ if (Z_TYPE_P(message) == IS_OBJECT) {
+ getObjectEx(http_message_object, msg, message);
+
+ array_init(return_value);
+
+ if (allowed_extras_array) {
+ allowed_extras = ecalloc(zend_hash_num_elements(Z_ARRVAL_P(allowed_extras_array)) + 1, sizeof(char *));
+ FOREACH_VAL(pos, allowed_extras_array, entry) {
+ ZVAL_ADDREF(*entry);
+ convert_to_string_ex(entry);
+ allowed_extras[i++] = estrndup(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry));
+ zval_ptr_dtor(entry);
+ }
+ }
+
+ FOREACH_HASH_KEYVAL(pos1, &msg->message->hdrs, key, idx, header) {
+ if (key && !strcasecmp(key, "Set-Cookie")) {
+ http_cookie_list list;
+
+ if (Z_TYPE_PP(header) == IS_ARRAY) {
+ zval **single_header;
+
+ FOREACH_VAL(pos2, *header, single_header) {
+ ZVAL_ADDREF(*single_header);
+ convert_to_string_ex(single_header);
+ if (http_parse_cookie_ex(&list, Z_STRVAL_PP(single_header), flags, allowed_extras)) {
+ zval *cookie;
+
+ MAKE_STD_ZVAL(cookie);
+ object_init(cookie);
+ http_cookie_list_tostruct(&list, cookie);
+ add_next_index_zval(return_value, cookie);
+ http_cookie_list_dtor(&list);
+ }
+ zval_ptr_dtor(single_header);
+ }
+ } else {
+ ZVAL_ADDREF(*header);
+ convert_to_string_ex(header);
+ if (http_parse_cookie_ex(&list, Z_STRVAL_PP(header), flags, allowed_extras)) {
+ zval *cookie;
+
+ MAKE_STD_ZVAL(cookie);
+ object_init(cookie);
+ http_cookie_list_tostruct(&list, cookie);
+ add_next_index_zval(return_value, cookie);
+ http_cookie_list_dtor(&list);
+ }
+ zval_ptr_dtor(header);
+ }
+ }
+ /* reset key */
+ key = NULL;
+ }
+
+ if (allowed_extras) {
+ for (i = 0; allowed_extras[i]; ++i) {
+ efree(allowed_extras[i]);
+ }
+ efree(allowed_extras);
+ }
+
+ return;
+ }
+ }
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto string HttpRequest::getResponseBody()
+ *
+ * Get the response body after the request has been sent.
+ *
+ * Returns a string containing the response body.
+ *
+ * If redirects were allowed and several responses were received, the data
+ * references the last received response.
+ */
+PHP_METHOD(HttpRequest, getResponseBody)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ zval *message = GET_PROP(responseMessage);
+
+ if (Z_TYPE_P(message) == IS_OBJECT) {
+ getObjectEx(http_message_object, msg, message);
+ RETURN_PHPSTR_DUP(&msg->message->body);
+ } else {
+ RETURN_FALSE;
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto int HttpRequest::getResponseCode()
+ *
+ * Get the response code after the request has been sent.
+ *
+ * Returns an int representing the response code.
+ *
+ * If redirects were allowed and several responses were received, the data
+ * references the last received response.
+ */
+PHP_METHOD(HttpRequest, getResponseCode)
+{
+ NO_ARGS;