+/* {{{ proto static bool HttpResponse::setHeader(string name, mixed value[, bool replace = true)
+ */
+PHP_METHOD(HttpResponse, setHeader)
+{
+ zend_bool replace = 1;
+ char *name;
+ int name_len = 0;
+ zval *value = NULL, *headers, **header;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/!|b", &name, &name_len, &value, &replace)) {
+ RETURN_FALSE;
+ }
+ if (!name_len) {
+ http_error(HE_WARNING, HTTP_E_HEADER, "Cannot send anonymous headers");
+ RETURN_FALSE;
+ }
+
+ headers = GET_STATIC_PROP(headers);
+
+ if (Z_TYPE_P(headers) != IS_ARRAY) {
+ convert_to_array(headers);
+ }
+
+ /* delete header if value == null */
+ if (!value || Z_TYPE_P(value) == IS_NULL) {
+ RETURN_SUCCESS(zend_hash_del(Z_ARRVAL_P(headers), name, name_len + 1));
+ }
+
+ if (Z_TYPE_P(value) != IS_STRING) {
+ convert_to_string_ex(&value);
+ }
+
+ /* convert old header to an array and add new one if header exists and replace == false */
+ if (replace || (SUCCESS != zend_hash_find(Z_ARRVAL_P(headers), name, name_len + 1, (void **) &header))) {
+ RETURN_SUCCESS(add_assoc_stringl_ex(headers, name, name_len + 1, Z_STRVAL_P(value), Z_STRLEN_P(value), 1));
+ } else {
+ convert_to_array(*header);
+ RETURN_SUCCESS(add_next_index_stringl(*header, Z_STRVAL_P(value), Z_STRLEN_P(value), 1));
+ }
+}
+/* }}} */
+
+/* {{{ proto static mixed HttpResponse::getHeader([string name])
+ */
+PHP_METHOD(HttpResponse, getHeader)
+{
+ char *name = NULL;
+ int name_len = 0;
+ zval *headers, **header;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len)) {
+ RETURN_FALSE;
+ }
+
+ headers = GET_STATIC_PROP(headers);
+ if (Z_TYPE_P(headers) != IS_ARRAY) {
+ convert_to_array(headers);
+ }
+
+ if (!name || !name_len) {
+ array_init(return_value);
+ array_copy(headers, return_value);
+ } else if (SUCCESS == zend_hash_find(Z_ARRVAL_P(headers), name, name_len + 1, (void **) &header)) {
+ RETURN_ZVAL(*header, ZVAL_PTR_DTOR, 1);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto static bool HttpResponse::setCache(bool cache)