cvs: pecl /soap TODO php_http.c soap.c
| From: | Dmitry Stogov | Date: | Thu, 08 Jan 2004 09:56:49 +0000 |
| Subject: | cvs: pecl /soap TODO php_http.c soap.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-680@lists.php.net to get a copy of this message | ||
dmitry Thu Jan 8 04:56:49 2004 EDT
Modified files:
/pecl/soap TODO php_http.c soap.c
Log:
HTTP Authentication was implemented
Index: pecl/soap/TODO
diff -u pecl/soap/TODO:1.4 pecl/soap/TODO:1.5
--- pecl/soap/TODO:1.4 Tue Jan 6 12:14:30 2004
+++ pecl/soap/TODO Thu Jan 8 04:56:49 2004
@@ -108,7 +108,7 @@
+ support for https://
- support for persistent HTTP connections (keep_alive)
- support for HTTP compression (gzip,x-gzip,defalte)
-- support for HTTP athentication
++ support for HTTP authentication
- support for HTTP proxies
- transport abstraction layer
Index: pecl/soap/php_http.c
diff -u pecl/soap/php_http.c:1.12 pecl/soap/php_http.c:1.13
--- pecl/soap/php_http.c:1.12 Tue Jan 6 12:12:52 2004
+++ pecl/soap/php_http.c Thu Jan 8 04:56:49 2004
@@ -1,4 +1,5 @@
#include "php_soap.h"
+#include "ext/standard/base64.h"
static char *get_http_header_value(char *headers, char *type);
static int get_http_body(php_stream *socketd, char *headers, char **response, int *out_size
TSRMLS_DC);
@@ -112,7 +113,7 @@
}
if (stream) {
- zval **cookies;
+ zval **cookies, **login, **password;
smart_str_append_const(&soap_headers, "POST ");
smart_str_appends(&soap_headers, phpurl->path);
@@ -132,7 +133,24 @@
smart_str_appends(&soap_headers, soapaction);
smart_str_append_const(&soap_headers, "\"\r\n");
- /* TODO: Add authentication */
+ /* HTTP Authentication */
+ if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void
**)&login) == SUCCESS) {
+ char* buf;
+ int len;
+
+ smart_str auth = {0};
+ smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
+ smart_str_appendc(&auth, ':');
+ if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"),
(void **)&password) == SUCCESS) {
+ smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
+ }
+ buf = php_base64_encode(auth.c, auth.len, &len);
+ smart_str_append_const(&soap_headers, "Authorization: Basic ");
+ smart_str_appendl(&soap_headers, buf, len);
+ smart_str_append_const(&soap_headers, "\r\n");
+ efree(buf);
+ smart_str_free(&auth);
+ }
/* Send cookies along with request */
if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"),
(void **)&cookies) == SUCCESS) {
Index: pecl/soap/soap.c
diff -u pecl/soap/soap.c:1.19 pecl/soap/soap.c:1.20
--- pecl/soap/soap.c:1.19 Tue Jan 6 12:14:30 2004
+++ pecl/soap/soap.c Thu Jan 8 04:56:49 2004
@@ -84,6 +84,7 @@
PHP_METHOD(soapobject, __isfault);
PHP_METHOD(soapobject, __getfault);
PHP_METHOD(soapobject, __call);
+PHP_METHOD(soapobject, __login);
PHP_METHOD(soapobject, __trace);
PHP_METHOD(soapobject, __getfunctions);
PHP_METHOD(soapobject, __gettypes);
@@ -133,6 +134,7 @@
PHP_ME(soapobject, __getfault, NULL, 0)
PHP_ME(soapobject, __use, NULL, 0)
PHP_ME(soapobject, __style, NULL, 0)
+ PHP_ME(soapobject, __login, NULL, 0)
PHP_ME(soapobject, __call, NULL, 0)
PHP_ME(soapobject, __trace, NULL, 0)
PHP_ME(soapobject, __getlastrequest, NULL, 0)
@@ -1481,6 +1483,24 @@
SOAP_GLOBAL(sdl) = NULL;
}
+PHP_METHOD(soapobject, __login)
+{
+ char *login_name;
+ char *login_pass;
+ int login_name_len;
+ int login_pass_len;
+ zval* thisObj;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &login_name, &login_name_len, &login_pass, &login_pass_len) == FAILURE) {
+ return;
+ }
+ GET_THIS_OBJECT(thisObj);
+ add_property_stringl(thisObj,"_login",login_name,login_name_len, 1);
+ add_property_stringl(thisObj,"_password",login_pass,login_pass_len, 1);
+}
+
+
PHP_METHOD(soapobject, __call)
{
char *function, *soap_action, *uri;