- zval *supported;
- char *def = NULL;
- int def_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|s", &supported, &def, &def_len) != SUCCESS) {
- RETURN_FALSE;
- }
-
- if (!def) {
- def = "iso-8859-1";
- }
-
- RETURN_STRING(http_negotiate_charset(supported, def), 0);
-}
-/* }}} */
-
-/* {{{ proto bool http_send_status(int status)
- *
- * Send HTTP status code.
- *
- */
-PHP_FUNCTION(http_send_status)
-{
- int status = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status) != SUCCESS) {
- RETURN_FALSE;
- }
- if (status < 100 || status > 510) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid HTTP status code (100-510): %d", status);
- RETURN_FALSE;
- }
-
- RETURN_SUCCESS(http_send_status(status));
-}
-/* }}} */
-
-/* {{{ proto bool http_send_last_modified([int timestamp])
- *
- * This converts the given timestamp to a valid HTTP date and
- * sends it as "Last-Modified" HTTP header. If timestamp is
- * omitted, current time is sent.
- *
- */
-PHP_FUNCTION(http_send_last_modified)
-{
- long t = -1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &t) != SUCCESS) {
- RETURN_FALSE;
- }
-
- if (t == -1) {
- t = (long) time(NULL);
- }
-
- RETURN_SUCCESS(http_send_last_modified(t));
-}
-/* }}} */
-
-/* {{{ proto bool http_match_modified([int timestamp])
- *
- * Matches the given timestamp against the clients "If-Modified-Since" resp.
- * "If-Unmodified-Since" HTTP headers.
- *
- */
-PHP_FUNCTION(http_match_modified)
-{
- long t = -1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &t) != SUCCESS) {
- RETURN_FALSE;
- }
-
- // current time if not supplied (senseless though)
- if (t == -1) {
- t = (long) time(NULL);
- }
-
- RETURN_BOOL(http_modified_match("HTTP_IF_MODIFIED_SINCE", t) || http_modified_match("HTTP_IF_UNMODIFIED_SINCE", t));
-}
-/* }}} */
-
-/* {{{ proto bool http_match_etag(string etag)
- *
- * This matches the given ETag against the clients
- * "If-Match" resp. "If-None-Match" HTTP headers.
- *
- */
-PHP_FUNCTION(http_match_etag)
-{
- int etag_len;
- char *etag;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &etag, &etag_len) != SUCCESS) {
- RETURN_FALSE;
- }
-
- RETURN_BOOL(http_etag_match("HTTP_IF_NONE_MATCH", etag) || http_etag_match("HTTP_IF_MATCH", etag));
-}
-/* }}} */
-
-/* {{{ proto bool http_cache_last_modified([int timestamp_or_expires]])
- *
- * If timestamp_or_exires is greater than 0, it is handled as timestamp
- * and will be sent as date of last modification. If it is 0 or omitted,
- * the current time will be sent as Last-Modified date. If it's negative,
- * it is handled as expiration time in seconds, which means that if the
- * requested last modification date is not between the calculated timespan,
- * the Last-Modified header is updated and the actual body will be sent.
- *
- */
-PHP_FUNCTION(http_cache_last_modified)
-{
- long last_modified = 0, send_modified = 0, t;
- zval *zlm;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &last_modified) != SUCCESS) {
- RETURN_FALSE;
- }
-
- t = (long) time(NULL);
-
- /* 0 or omitted */
- if (!last_modified) {
- /* does the client have? (att: caching "forever") */
- if (zlm = http_get_server_var("HTTP_IF_MODIFIED_SINCE")) {
- last_modified = send_modified = http_parse_date(Z_STRVAL_P(zlm));
- /* send current time */
- } else {
- send_modified = t;
- }
- /* negative value is supposed to be expiration time */
- } else if (last_modified < 0) {
- last_modified += t;
- send_modified = t;
- /* send supplied time explicitly */
- } else {
- send_modified = last_modified;
- }
-
- http_send_header("Cache-Control: private, must-revalidate, max-age=0");
-
- if (http_modified_match("HTTP_IF_MODIFIED_SINCE", last_modified)) {
- if (SUCCESS == http_send_status(304)) {
- zend_bailout();
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not send 304 Not Modified");
- RETURN_FALSE;
- }
- }
- RETURN_SUCCESS(http_send_last_modified(send_modified));
+ G->send.buffer_size = HTTP_SENDBUF_SIZE;
+ zend_hash_init(&G->request.methods.custom, 0, NULL, ZVAL_PTR_DTOR, 0);
+#ifdef HTTP_HAVE_CURL
+ zend_llist_init(&G->request.copies.strings, sizeof(char *), http_request_data_free_string, 0);
+ zend_llist_init(&G->request.copies.slists, sizeof(struct curl_slist *), http_request_data_free_slist, 0);
+ zend_llist_init(&G->request.copies.contexts, sizeof(http_curl_callback_ctx *), http_request_data_free_context, 0);
+ zend_llist_init(&G->request.copies.convs, sizeof(http_curl_conv *), http_request_data_free_conv, 0);
+#endif