#include "php_http_request_object.h"
#include "php_http_request_api.h"
#include "php_http_request_pool_api.h"
+#include "php_http.h"
#include "php_http_api.h"
#include "php_http_url_api.h"
#include "php_http_message_api.h"
#define HTTP_BEGIN_ARGS(method, ret_ref, req_args) HTTP_BEGIN_ARGS_EX(HttpRequest, method, ret_ref, req_args)
#define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpRequest, method, ret_ref)
#define HTTP_REQUEST_ME(method, visibility) PHP_ME(HttpRequest, method, HTTP_ARGS(HttpRequest, method), visibility)
+#define HTTP_REQUEST_ALIAS(method, func) HTTP_STATIC_ME_ALIAS(method, func, HTTP_ARGS(HttpRequest, method))
HTTP_EMPTY_ARGS(__destruct, 0);
HTTP_BEGIN_ARGS(__construct, 0, 0)
HTTP_EMPTY_ARGS(getResponseMessage, 1);
HTTP_EMPTY_ARGS(send, 0);
+HTTP_BEGIN_ARGS(get, 1, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(options, 0)
+ HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(head, 1, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(options, 0)
+ HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(postData, 2, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(data, 0)
+ HTTP_ARG_VAL(options, 0)
+ HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(postFields, 2, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(data, 0)
+ HTTP_ARG_VAL(options, 0)
+ HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(putFile, 2, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(file, 0)
+ HTTP_ARG_VAL(options, 0)
+ HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(putStream, 2, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(stream, 0)
+ HTTP_ARG_VAL(options, 0)
+ HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(methodRegister, 1, 0)
+ HTTP_ARG_VAL(method_name, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(methodUnregister, 1, 0)
+ HTTP_ARG_VAL(method, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(methodName, 1, 0)
+ HTTP_ARG_VAL(method_id, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(methodExists, 1, 0)
+ HTTP_ARG_VAL(method, 0)
+HTTP_END_ARGS;
+
#define http_request_object_declare_default_properties() _http_request_object_declare_default_properties(TSRMLS_C)
static inline void _http_request_object_declare_default_properties(TSRMLS_D);
HTTP_REQUEST_ME(getResponseInfo, ZEND_ACC_PUBLIC)
HTTP_REQUEST_ME(getResponseMessage, ZEND_ACC_PUBLIC)
+ HTTP_REQUEST_ALIAS(get, http_get)
+ HTTP_REQUEST_ALIAS(head, http_head)
+ HTTP_REQUEST_ALIAS(postData, http_post_data)
+ HTTP_REQUEST_ALIAS(postFields, http_post_fields)
+ HTTP_REQUEST_ALIAS(putFile, http_put_file)
+ HTTP_REQUEST_ALIAS(putStream, http_put_stream)
+
+ HTTP_REQUEST_ALIAS(methodRegister, http_request_method_register)
+ HTTP_REQUEST_ALIAS(methodUnregister, http_request_method_unregister)
+ HTTP_REQUEST_ALIAS(methodName, http_request_method_name)
+ HTTP_REQUEST_ALIAS(methodExists, http_request_method_exists)
+
{NULL, NULL, NULL}
};
static zend_object_handlers http_request_object_handlers;
#include "SAPI.h"
#include "php_ini.h"
+#include "ext/standard/head.h"
#include "php_http.h"
#include "php_http_api.h"
#define HTTP_BEGIN_ARGS(method, req_args) HTTP_BEGIN_ARGS_EX(HttpResponse, method, 0, req_args)
#define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpResponse, method, ret_ref)
#define HTTP_RESPONSE_ME(method, visibility) PHP_ME(HttpResponse, method, HTTP_ARGS(HttpResponse, method), visibility|ZEND_ACC_STATIC)
+#define HTTP_RESPONSE_ALIAS(method, func) HTTP_STATIC_ME_ALIAS(method, func, HTTP_ARGS(HttpResponse, method))
HTTP_EMPTY_ARGS(getETag, 0);
HTTP_BEGIN_ARGS(setETag, 1)
HTTP_EMPTY_ARGS(capture, 0);
+HTTP_BEGIN_ARGS(redirect, 0)
+ HTTP_ARG_VAL(url, 0)
+ HTTP_ARG_VAL(params, 0)
+ HTTP_ARG_VAL(session, 0)
+ HTTP_ARG_VAL(permanent, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(sendStatus, 1)
+ HTTP_ARG_VAL(status, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(sendHeader, 1)
+ HTTP_ARG_VAL(header, 0)
+ HTTP_ARG_VAL(replace, 0)
+ HTTP_ARG_VAL(status, 0)
+HTTP_END_ARGS;
+
+HTTP_EMPTY_ARGS(getRequestHeaders, 0);
+HTTP_EMPTY_ARGS(getRequestBody, 0);
+
#define http_response_object_declare_default_properties() _http_response_object_declare_default_properties(TSRMLS_C)
static inline void _http_response_object_declare_default_properties(TSRMLS_D);
HTTP_RESPONSE_ME(send, ZEND_ACC_PUBLIC)
HTTP_RESPONSE_ME(capture, ZEND_ACC_PUBLIC)
+ HTTP_RESPONSE_ALIAS(redirect, http_redirect)
+
+ HTTP_RESPONSE_ALIAS(sendStatus, http_send_status)
+ HTTP_RESPONSE_ALIAS(sendHeader, header)
+
+ HTTP_RESPONSE_ALIAS(getRequestHeaders, http_get_request_headers)
+ HTTP_RESPONSE_ALIAS(getRequestBody, http_get_request_body)
+
{NULL, NULL, NULL}
};
#include "php_http_std_defs.h"
#include "php_http_util_object.h"
-HTTP_DECLARE_ARG_PASS_INFO();
-
zend_class_entry *http_util_object_ce;
zend_function_entry http_util_object_fe[] = {
HTTP_STATIC_ME_ALIAS(date, http_date, NULL)
HTTP_STATIC_ME_ALIAS(absoluteURI, http_absolute_uri, NULL)
HTTP_STATIC_ME_ALIAS(negotiateLanguage, http_negotiate_language, NULL)
HTTP_STATIC_ME_ALIAS(negotiateCharset, http_negotiate_charset, NULL)
- HTTP_STATIC_ME_ALIAS(redirect, http_redirect, NULL)
- HTTP_STATIC_ME_ALIAS(sendStatus, http_send_status, NULL)
- HTTP_STATIC_ME_ALIAS(sendLastModified, http_send_last_modified, NULL)
- HTTP_STATIC_ME_ALIAS(sendContentType, http_send_content_type, NULL)
- HTTP_STATIC_ME_ALIAS(sendContentDisposition, http_send_content_disposition, NULL)
HTTP_STATIC_ME_ALIAS(matchModified, http_match_modified, NULL)
HTTP_STATIC_ME_ALIAS(matchEtag, http_match_etag, NULL)
- HTTP_STATIC_ME_ALIAS(cacheLastModified, http_cache_last_modified, NULL)
- HTTP_STATIC_ME_ALIAS(cacheEtag, http_cache_etag, NULL)
HTTP_STATIC_ME_ALIAS(chunkedDecode, http_chunked_decode, NULL)
HTTP_STATIC_ME_ALIAS(splitResponse, http_split_response, NULL)
HTTP_STATIC_ME_ALIAS(parseHeaders, http_parse_headers, NULL)
- HTTP_STATIC_ME_ALIAS(getRequestHeaders, http_get_request_headers, NULL)
- HTTP_STATIC_ME_ALIAS(getRequestBody, http_get_request_body, NULL)
-#ifdef HTTP_HAVE_CURL
- HTTP_STATIC_ME_ALIAS(get, http_get, http_arg_pass_ref_3)
- HTTP_STATIC_ME_ALIAS(head, http_head, http_arg_pass_ref_3)
- HTTP_STATIC_ME_ALIAS(postData, http_post_data, http_arg_pass_ref_4)
- HTTP_STATIC_ME_ALIAS(postFields, http_post_fields, http_arg_pass_ref_5)
-#endif /* HTTP_HAVE_CURL */
HTTP_STATIC_ME_ALIAS(authBasic, http_auth_basic, NULL)
HTTP_STATIC_ME_ALIAS(authBasicCallback, http_auth_basic_cb, NULL)
{NULL, NULL, NULL}
PHP_METHOD(HttpRequest, getResponseInfo);
PHP_METHOD(HttpRequest, getResponseMessage);
+PHP_METHOD(HttpRequest, get);
+PHP_METHOD(HttpRequest, head);
+PHP_METHOD(HttpRequest, postData);
+PHP_METHOD(HttpRequest, postFields);
+PHP_METHOD(HttpRequest, putFile);
+PHP_METHOD(HttpRequest, putStream);
+
+PHP_METHOD(HttpRequest, methodRegister);
+PHP_METHOD(HttpRequest, methodUnregister);
+PHP_METHOD(HttpRequest, methodName);
+PHP_METHOD(HttpRequest, methodExists);
+
#endif
#endif
#endif
PHP_METHOD(HttpResponse, getStream);
PHP_METHOD(HttpResponse, send);
PHP_METHOD(HttpResponse, capture);
+PHP_METHOD(HttpResponse, redirect);
+PHP_METHOD(HttpResponse, sendStatus);
+PHP_METHOD(HttpResponse, sendHeader);
+PHP_METHOD(HttpResponse, getRequestHeaders);
+PHP_METHOD(HttpResponse, getRequestBody);
#endif
#endif
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);
-PHP_METHOD(HttpUtil, getRequestBody);
-#ifdef HTTP_HAVE_CURL
-PHP_METHOD(HttpUtil, get);
-PHP_METHOD(HttpUtil, head);
-PHP_METHOD(HttpUtil, postData);
-PHP_METHOD(HttpUtil, postFields);
-#endif /* HTTP_HAVE_CURL */
PHP_METHOD(HttpUtil, authBasic);
PHP_METHOD(HttpUtil, authBasicCallback);
--TEST--
HttpMessage
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
checkver(5);
?>
--FILE--
<?php
+echo "-TEST\n";
$m = new HttpMessage(
"HTTP/1.1 301\r\n".
"Location: /anywhere\r\n".
var_dump(HttpMessage::fromString($m->toString())->toString());
?>
--EXPECTF--
-%sstring(1) "X"
+%sTEST
+string(1) "X"
string(134) "HTTP/1.1 301
Location: /anywhere
HTTP/1.1 302
X
"
+
--TEST--
HttpRequest options
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
checkver(5);
?>
--FILE--
<?php
+echo "-TEST\n";
$r1 = new HttpRequest;
$r2 = new HttpRequest;
$r1->setOptions(array('redirect'=>11, 'headers'=>array('X-Foo'=>'Bar')));
$r2 = null;
?>
--EXPECTF--
-%sArray
+%sTEST
+Array
(
[0] => Array
(
)
)
-bool(false)
\ No newline at end of file
+bool(false)
--TEST--
http_absolute_uri() with relative paths
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
?>
--FILE--
<?php
+echo "-TEST\n";
echo http_absolute_uri('page'), "\n";
echo http_absolute_uri('with/some/path/'), "\n";
?>
--EXPECTF--
-%shttp://localhost/page
+%sTEST
+http://localhost/page
http://localhost/with/some/path/
+
--TEST--
http_absolute_uri() with proto
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
?>
--FILE--
<?php
+echo "-TEST\n";
echo http_absolute_uri('sec', 'https'), "\n";
echo http_absolute_uri('/pub', 'ftp'), "\n";
echo http_absolute_uri('/', null), "\n";
?>
--EXPECTF--
-%shttps://localhost/sec
+%sTEST
+https://localhost/sec
ftp://localhost/pub
http://localhost/
+
--TEST--
http_chunked_decode()
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
?>
--FILE--
<?php
-$data =
+echo "-TEST\n";
+$data =
"02\r\n".
"ab\r\n".
"03\r\n".
var_dump(http_chunked_decode($data));
?>
--EXPECTF--
-Content-type: text/html
-X-Powered-By: PHP/%s
-
+%sTEST
string(9) "aba
cabcd"
+
--TEST--
http_date() with timestamp
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
?>
--FILE--
<?php
+echo "-TEST\n";
echo http_date(1), "\n";
echo http_date(1234567890), "\n";
?>
--EXPECTF--
-%sThu, 01 Jan 1970 00:00:01 GMT
+%sTEST
+Thu, 01 Jan 1970 00:00:01 GMT
Fri, 13 Feb 2009 23:31:30 GMT
+
--TEST--
http_date() without timestamp
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
?>
--FILE--
<?php
+echo "-TEST\n";
$t = time();
$d1 = http_date($t);
$d2 = http_date($t);
echo strtotime($d1), "\n$d1\n$d2\n";
?>
--EXPECTF--
-%sbool(true)
+%sTEST
+bool(true)
%d
%s, %d %s %d %d:%d:%d GMT
%s, %d %s %d %d:%d:%d GMT
+
--TEST--
http_parse_headers()
--SKIPIF--
-<?php
+<?php
include 'skip.inc';
?>
--FILE--
<?php
+echo "-TEST\n";
print_r(http_parse_headers(
"Host: localhost\r\n".
"Host: ambigious\r\n".
));
?>
--EXPECTF--
-%sArray
+%sTEST
+Array
(
[Host] => Array
(
[Folded] => one
two
three
-)
\ No newline at end of file
+)
+
?>
--FILE--
<?php
+echo "-TEST\n";
$data = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nContent-Language: de-AT\r\nDate: Sat, 22 Jan 2005 18:10:02 GMT\r\n\r\nHallo Du!";
var_export(http_split_response($data));
echo "\nDone\n";
?>
--EXPECTF--
-%sarray (
+%sTEST
+array (
0 =>
array (
'Response Status' => '200 Ok',