- implement feature request: 'bodyonly' request option;
[m6w6/ext-http] / php_http.h
index fd925f69416975c0650484404ace860572f2da58..8e724af7ba09dcd259b6d08f46754dcbcd4ece4c 100644 (file)
@@ -1,16 +1,13 @@
 /*
-   +----------------------------------------------------------------------+
-   | PECL :: http                                                         |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license, that  |
-   | is bundled with this package in the file LICENSE, and is available   |
-   | through the world-wide-web at http://www.php.net/license/3_0.txt.    |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 2004-2005 Michael Wallner <mike@php.net>               |
-   +----------------------------------------------------------------------+
+    +--------------------------------------------------------------------+
+    | PECL :: http                                                       |
+    +--------------------------------------------------------------------+
+    | Redistribution and use in source and binary forms, with or without |
+    | modification, are permitted provided that the conditions mentioned |
+    | in the accompanying LICENSE file are met.                          |
+    +--------------------------------------------------------------------+
+    | Copyright (c) 2004-2005, Michael Wallner <mike@php.net>            |
+    +--------------------------------------------------------------------+
 */
 
 /* $Id$ */
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define HTTP_PEXT_VERSION "0.7.0-dev"
+#define PHP_EXT_HTTP_VERSION "0.20.0dev"
 
-/* make compile on Win32 */
-#include "php_streams.h"
-#include "ext/standard/md5.h"
+#include "php.h"
+#include "php_http_std_defs.h"
+#include "phpstr/phpstr.h"
+#include "missing.h"
 
-extern zend_module_entry http_module_entry;
-#define phpext_http_ptr &http_module_entry
 
-#ifdef ZTS
-#      include "TSRM.h"
-#      define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
-#else
-#      define HTTP_G(v) (http_globals.v)
+#ifdef HTTP_WANT_NETDB
+#      ifdef PHP_WIN32
+#              include <winsock2.h>
+#      elif defined(HAVE_NETDB_H)
+#              include <netdb.h>
+#      endif
 #endif
 
-#ifdef ZEND_ENGINE_2
+#if defined(HTTP_WANT_CURL) && defined(HTTP_HAVE_CURL)
+#      ifdef PHP_WIN32
+#              include <winsock2.h>
+#      endif
+#      include <curl/curl.h>
+#endif
 
-typedef struct {
-       zend_object     zo;
-} http_response_object;
+#if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)
+#      if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
+#              define USE_MAGIC_STATIC
+#      endif
+#      include <magic.h>
+#endif
 
-#ifdef HTTP_HAVE_CURL
+#if defined(HTTP_WANT_ZLIB) && defined(HTTP_HAVE_ZLIB)
+#      include <zlib.h>
+#endif
 
-#include "phpstr/phpstr.h"
+#include <ctype.h>
 
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
+extern zend_module_entry http_module_entry;
+#define phpext_http_ptr &http_module_entry
+
+extern int http_module_number;
+
+ZEND_BEGIN_MODULE_GLOBALS(http)
+
+       struct _http_globals_etag {
+               char *mode;
+               void *ctx;
+               zend_bool started;
+       } etag;
+
+       struct _http_globals_log {
+               char *cache;
+               char *redirect;
+               char *allowed_methods;
+               char *composite;
+       } log;
+
+       struct _http_globals_send {
+               double throttle_delay;
+               size_t buffer_size;
+               char *content_type;
+               char *unquoted_etag;
+               time_t last_modified;
+               int gzip_encoding;
+       } send;
+
+       struct _http_globals_request {
+               struct _http_globals_request_methods {
+                       char *allowed;
+                       HashTable custom;
+               } methods;
 
-#include <curl/curl.h>
-
-typedef struct {
-       zend_object zo;
-       CURL *ch;
-} http_request_object;
-
-typedef enum {
-       HTTP_GET,
-       HTTP_HEAD,
-       HTTP_POST,
-} http_request_method;
-
-#endif /* HTTP_HAVE _CURL */
-
-PHP_METHOD(HttpUtil, date);
-PHP_METHOD(HttpUtil, absoluteURI);
-PHP_METHOD(HttpUtil, negotiateLanguage);
-PHP_METHOD(HttpUtil, negotiateCharset);
-PHP_METHOD(HttpUtil, redirect);
-PHP_METHOD(HttpUtil, sendStatus);
-PHP_METHOD(HttpUtil, sendLastModified);
-PHP_METHOD(HttpUtil, sendContentType);
-PHP_METHOD(HttpUtil, sendContentDisposition);
-PHP_METHOD(HttpUtil, matchModified);
-PHP_METHOD(HttpUtil, matchEtag);
-PHP_METHOD(HttpUtil, cacheLastModified);
-PHP_METHOD(HttpUtil, cacheEtag);
-PHP_METHOD(HttpUtil, chunkedDecode);
-PHP_METHOD(HttpUtil, splitResponse);
-PHP_METHOD(HttpUtil, parseHeaders);
-PHP_METHOD(HttpUtil, getRequestHeaders);
 #ifdef HTTP_HAVE_CURL
-PHP_METHOD(HttpUtil, get);
-PHP_METHOD(HttpUtil, head);
-PHP_METHOD(HttpUtil, postData);
-PHP_METHOD(HttpUtil, postArray);
+               struct _http_globals_request_copies {
+                       zend_llist strings;
+                       zend_llist slists;
+                       zend_llist contexts;
+                       zend_llist convs;
+               } copies;
+#      ifndef HAVE_CURL_EASY_STRERROR
+               char error[CURL_ERROR_SIZE + 1];
+#      endif
 #endif /* HTTP_HAVE_CURL */
-PHP_METHOD(HttpUtil, authBasic);
-PHP_METHOD(HttpUtil, authBasicCallback);
-
-
-PHP_METHOD(HttpResponse, __construct);/*
-PHP_METHOD(HttpResponse, __destruct);*/
-PHP_METHOD(HttpResponse, setETag);
-PHP_METHOD(HttpResponse, getETag);
-PHP_METHOD(HttpResponse, setContentDisposition);
-PHP_METHOD(HttpResponse, getContentDisposition);
-PHP_METHOD(HttpResponse, setContentType);
-PHP_METHOD(HttpResponse, getContentType);
-PHP_METHOD(HttpResponse, setCache);
-PHP_METHOD(HttpResponse, getCache);
-PHP_METHOD(HttpResponse, setCacheControl);
-PHP_METHOD(HttpResponse, getCacheControl);
-PHP_METHOD(HttpResponse, setGzip);
-PHP_METHOD(HttpResponse, getGzip);
-PHP_METHOD(HttpResponse, setData);
-PHP_METHOD(HttpResponse, getData);
-PHP_METHOD(HttpResponse, setFile);
-PHP_METHOD(HttpResponse, getFile);
-PHP_METHOD(HttpResponse, setStream);
-PHP_METHOD(HttpResponse, getStream);
-PHP_METHOD(HttpResponse, send);
+       } request;
 
-#ifdef HTTP_HAVE_CURL
+#ifdef ZEND_ENGINE_2
+       zend_bool only_exceptions;
+#endif
 
-PHP_METHOD(HttpRequest, __construct);
-PHP_METHOD(HttpRequest, __destruct);
-PHP_METHOD(HttpRequest, setOptions);
-PHP_METHOD(HttpRequest, getOptions);
-PHP_METHOD(HttpRequest, unsetOptions);
-PHP_METHOD(HttpRequest, addHeader);
-PHP_METHOD(HttpRequest, addCookie);
-PHP_METHOD(HttpRequest, setMethod);
-PHP_METHOD(HttpRequest, getMethod);
-PHP_METHOD(HttpRequest, setURL);
-PHP_METHOD(HttpRequest, getURL);
-PHP_METHOD(HttpRequest, setContentType);
-PHP_METHOD(HttpRequest, getContentType);
-PHP_METHOD(HttpRequest, setQueryData);
-PHP_METHOD(HttpRequest, getQueryData);
-PHP_METHOD(HttpRequest, addQueryData);
-PHP_METHOD(HttpRequest, unsetQueryData);
-PHP_METHOD(HttpRequest, setPostData);
-PHP_METHOD(HttpRequest, getPostData);
-PHP_METHOD(HttpRequest, addPostData);
-PHP_METHOD(HttpRequest, unsetPostData);
-PHP_METHOD(HttpRequest, addPostFile);
-PHP_METHOD(HttpRequest, getPostFiles);
-PHP_METHOD(HttpRequest, unsetPostFiles);
-PHP_METHOD(HttpRequest, send);
-PHP_METHOD(HttpRequest, getResponseData);
-PHP_METHOD(HttpRequest, getResponseHeader);
-PHP_METHOD(HttpRequest, getResponseCode);
-PHP_METHOD(HttpRequest, getResponseBody);
-PHP_METHOD(HttpRequest, getResponseInfo);
+       zend_bool force_exit;
 
-#endif /* HTTP_HAVE_CURL */
+ZEND_END_MODULE_GLOBALS(http)
 
-#endif /* ZEND_ENGINE_2 */
+#ifdef ZTS
+#      include "TSRM.h"
+#      define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
+#      define HTTP_GLOBALS ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
+#else
+#      define HTTP_G(v) (http_globals.v)
+#      define HTTP_GLOBALS (&http_globals)
+#endif
+#define getGlobals(G) zend_http_globals *G = HTTP_GLOBALS;
 
 PHP_FUNCTION(http_test);
 PHP_FUNCTION(http_date);
-PHP_FUNCTION(http_absolute_uri);
+PHP_FUNCTION(http_build_uri);
 PHP_FUNCTION(http_negotiate_language);
 PHP_FUNCTION(http_negotiate_charset);
+PHP_FUNCTION(http_negotiate_content_type);
 PHP_FUNCTION(http_redirect);
+PHP_FUNCTION(http_throttle);
 PHP_FUNCTION(http_send_status);
 PHP_FUNCTION(http_send_last_modified);
 PHP_FUNCTION(http_send_content_type);
@@ -167,21 +137,36 @@ PHP_FUNCTION(http_send_data);
 PHP_FUNCTION(http_send_file);
 PHP_FUNCTION(http_send_stream);
 PHP_FUNCTION(http_chunked_decode);
-PHP_FUNCTION(http_split_response);
+PHP_FUNCTION(http_parse_message);
 PHP_FUNCTION(http_parse_headers);
 PHP_FUNCTION(http_get_request_headers);
+PHP_FUNCTION(http_get_request_body);
+PHP_FUNCTION(http_match_request_header);
 #ifdef HTTP_HAVE_CURL
 PHP_FUNCTION(http_get);
 PHP_FUNCTION(http_head);
 PHP_FUNCTION(http_post_data);
-PHP_FUNCTION(http_post_array);
+PHP_FUNCTION(http_post_fields);
+PHP_FUNCTION(http_put_file);
+PHP_FUNCTION(http_put_stream);
 #endif /* HTTP_HAVE_CURL */
-PHP_FUNCTION(http_auth_basic);
-PHP_FUNCTION(http_auth_basic_cb);
+PHP_FUNCTION(http_request_method_register);
+PHP_FUNCTION(http_request_method_unregister);
+PHP_FUNCTION(http_request_method_exists);
+PHP_FUNCTION(http_request_method_name);
 #ifndef ZEND_ENGINE_2
 PHP_FUNCTION(http_build_query);
 #endif /* ZEND_ENGINE_2 */
-PHP_FUNCTION(ob_httpetaghandler);
+PHP_FUNCTION(ob_etaghandler);
+#ifdef HTTP_HAVE_ZLIB
+PHP_FUNCTION(http_gzencode);
+PHP_FUNCTION(http_gzdecode);
+PHP_FUNCTION(http_deflate);
+PHP_FUNCTION(http_inflate);
+PHP_FUNCTION(http_compress);
+PHP_FUNCTION(http_uncompress);
+#endif
+PHP_FUNCTION(http_support);
 
 PHP_MINIT_FUNCTION(http);
 PHP_MSHUTDOWN_FUNCTION(http);
@@ -189,20 +174,6 @@ PHP_RINIT_FUNCTION(http);
 PHP_RSHUTDOWN_FUNCTION(http);
 PHP_MINFO_FUNCTION(http);
 
-ZEND_BEGIN_MODULE_GLOBALS(http)
-       zend_bool etag_started;
-       PHP_MD5_CTX etag_md5;
-       php_stream_statbuf ssb;
-       char *ctype;
-       char *etag;
-       time_t lmod;
-       char *allowed_methods;
-#ifdef HTTP_HAVE_CURL
-       phpstr curlbuf;
-       zend_llist to_free;
-#endif /* HTTP_HAVE_CURL */
-ZEND_END_MODULE_GLOBALS(http)
-
 #endif /* PHP_HTTP_H */
 
 /*