]> granicus.if.org Git - php/commitdiff
Support for domain cookies
authorDmitry Stogov <dmitry@php.net>
Fri, 2 Apr 2004 15:43:41 +0000 (15:43 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 2 Apr 2004 15:43:41 +0000 (15:43 +0000)
ext/soap/php_http.c

index 08068e3814145ec8c3e754f9dad302c844ca7ef5..6072c3245a80e9b3ffc47d4e93e9f7e62a26f093 100644 (file)
@@ -171,6 +171,21 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in
        return stream;
 }
 
+static int in_domain(const char *host, const char *domain)
+{
+  if (domain[0] == '.') {
+    int l1 = strlen(host);
+    int l2 = strlen(domain);
+    if (l1 > l2) {
+       return strcmp(host+l1-l2,domain) == 0;
+    } else {
+      return 0;
+    }
+  } else {
+    return strcmp(host,domain) == 0;
+  }
+}
+
 int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *soapaction, int soap_version TSRMLS_DC)
 {
        xmlChar *buf, *request;
@@ -440,7 +455,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
                                                  if (zend_hash_index_find(Z_ARRVAL_PP(data), 1, (void**)&tmp) == SUCCESS &&
                                                      strncmp(phpurl->path,Z_STRVAL_PP(tmp),Z_STRLEN_PP(tmp)) == 0 &&
                                                      zend_hash_index_find(Z_ARRVAL_PP(data), 2, (void**)&tmp) == SUCCESS &&
-                                                     strcmp(phpurl->host,Z_STRVAL_PP(tmp)) == 0 &&
+                                                     in_domain(phpurl->host,Z_STRVAL_PP(tmp)) &&
                                                      (use_ssl || zend_hash_index_find(Z_ARRVAL_PP(data), 3, (void**)&tmp) == FAILURE)) {
                                                                smart_str_appendl(&soap_headers, key, strlen(key));
                                                                smart_str_appendc(&soap_headers, '=');