~ubuntu-branches/ubuntu/lucid/php5/lucid

« back to all changes in this revision

Viewing changes to ext/soap/php_http.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-03-16 09:09:50 UTC
  • mfrom: (1.1.18 upstream) (0.3.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100316090950-e36m0pzranoixifd
Tags: 5.3.2-1ubuntu1
* Merge from debian unstable: 
  - debian/control:
    * Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
    * Dropped libmysqlclient15-dev, build against mysql 5.1.
    * Dropped libcurl-dev not in the archive.
    * Suggest php5-suhosin rather than recommends.
    * Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions already in
      universe.
    * Dropped libonig-dev and libqgdbm since its in universe. (will be re-added in lucid+1)
    * Dropped locales-all.
  - modulelist: Drop imap, interbase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
  - Dropped debian/patches/libedit_is_editline.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
  +----------------------------------------------------------------------+
3
3
  | PHP Version 5                                                        |
4
4
  +----------------------------------------------------------------------+
5
 
  | Copyright (c) 1997-2009 The PHP Group                                |
 
5
  | Copyright (c) 1997-2010 The PHP Group                                |
6
6
  +----------------------------------------------------------------------+
7
7
  | This source file is subject to version 3.01 of the PHP license,      |
8
8
  | that is bundled with this package in the file LICENSE, and is        |
17
17
  |          Dmitry Stogov <dmitry@zend.com>                             |
18
18
  +----------------------------------------------------------------------+
19
19
*/
20
 
/* $Id: php_http.c 281589 2009-06-03 12:39:50Z iliaa $ */
 
20
/* $Id: php_http.c 294456 2010-02-03 20:29:09Z pajoye $ */
21
21
 
22
22
#include "php_soap.h"
23
23
#include "ext/standard/base64.h"
207
207
        int http_1_1;
208
208
        int http_status;
209
209
        int content_type_xml = 0;
 
210
        long redirect_max = 20;
210
211
        char *content_encoding;
211
212
        char *http_msg = NULL;
212
213
        zend_bool old_allow_url_fopen;
283
284
                context = php_stream_context_from_zval(*tmp, 0);
284
285
        }
285
286
 
 
287
        if (context && 
 
288
                php_stream_context_get_option(context, "http", "max_redirects", &tmp) == SUCCESS) {
 
289
                if (Z_TYPE_PP(tmp) != IS_STRING || !is_numeric_string(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &redirect_max, NULL, 1)) {
 
290
                        if (Z_TYPE_PP(tmp) == IS_LONG)
 
291
                                redirect_max = Z_LVAL_PP(tmp);
 
292
                }
 
293
        }
 
294
 
286
295
try_again:
287
296
        if (phpurl == NULL || phpurl->host == NULL) {
288
297
          if (phpurl != NULL) {php_url_free(phpurl);}
752
761
                err = php_stream_write(stream, soap_headers.c, soap_headers.len);
753
762
                if (err != soap_headers.len) {
754
763
                        if (request != buf) {efree(request);}
755
 
                        smart_str_free(&soap_headers);
756
764
                        php_stream_close(stream);
757
765
                        zend_hash_del(Z_OBJPROP_P(this_ptr), "httpurl", sizeof("httpurl"));
758
766
                        zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
759
767
                        zend_hash_del(Z_OBJPROP_P(this_ptr), "_use_proxy", sizeof("_use_proxy"));
760
768
                        add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL TSRMLS_CC);
 
769
                        smart_str_free(&soap_headers_z);
761
770
                        return FALSE;
762
771
                }
763
772
                smart_str_free(&soap_headers);
764
 
 
765
773
        } else {
766
774
                add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL TSRMLS_CC);
767
775
                smart_str_free(&soap_headers_z);
990
998
                                        new_url->host = phpurl->host ? estrdup(phpurl->host) : NULL;
991
999
                                        new_url->port = phpurl->port;
992
1000
                                        if (new_url->path && new_url->path[0] != '/') {
993
 
                                                char *t = phpurl->path;
994
 
                                                char *p = strrchr(t, '/');
995
 
                                                if (p) {
996
 
                                                        char *s = emalloc((p - t) + strlen(new_url->path) + 2);
997
 
                                                        strncpy(s, t, (p - t) + 1);
998
 
                                                        s[(p - t) + 1] = 0;
 
1001
                                                if (phpurl->path) {
 
1002
                                                        char *t = phpurl->path;
 
1003
                                                        char *p = strrchr(t, '/');
 
1004
                                                        if (p) {
 
1005
                                                                char *s = emalloc((p - t) + strlen(new_url->path) + 2);
 
1006
                                                                strncpy(s, t, (p - t) + 1);
 
1007
                                                                s[(p - t) + 1] = 0;
 
1008
                                                                strcat(s, new_url->path);
 
1009
                                                                efree(new_url->path);
 
1010
                                                                new_url->path = s;
 
1011
                                                        } 
 
1012
                                                } else {
 
1013
                                                        char *s = emalloc(strlen(new_url->path) + 2);
 
1014
                                                        s[0] = '/'; s[1] = 0;
999
1015
                                                        strcat(s, new_url->path);
1000
1016
                                                        efree(new_url->path);
1001
1017
                                                        new_url->path = s;
1004
1020
                                }
1005
1021
                                phpurl = new_url;
1006
1022
 
 
1023
                                if (--redirect_max < 1) {
 
1024
                                        add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL TSRMLS_CC);
 
1025
                                        smart_str_free(&soap_headers_z);
 
1026
                                        return FALSE;
 
1027
                                }
 
1028
 
1007
1029
                                goto try_again;
1008
1030
                        }
1009
1031
                }