From: Michael Wallner Date: Mon, 6 Nov 2006 07:53:46 +0000 (+0000) Subject: - fix PUT abort when neither putData nor putFile is set X-Git-Tag: RELEASE_1_4_0RC1~22 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ac9c991bb9b860c290004fbb57c273737527a1d5;p=m6w6%2Fext-http - fix PUT abort when neither putData nor putFile is set --- diff --git a/http_request_object.c b/http_request_object.c index 7e110b9..f158ceb 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -542,21 +542,23 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ case HTTP_PUT: { - zval *put_data = GET_PROP(putData); + zval *put_file = GET_PROP(putFile); http_request_object_check_request_content_type(getThis()); - if (Z_STRLEN_P(put_data)) { - obj->request->body = http_request_body_init_ex(obj->request->body, HTTP_REQUEST_BODY_CSTRING, - estrndup(Z_STRVAL_P(put_data), Z_STRLEN_P(put_data)), Z_STRLEN_P(put_data), 1); - } else { + + if (Z_STRLEN_P(put_file)) { php_stream_statbuf ssb; - php_stream *stream = php_stream_open_wrapper_ex(Z_STRVAL_P(GET_PROP(putFile)), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL, HTTP_DEFAULT_STREAM_CONTEXT); + php_stream *stream = php_stream_open_wrapper_ex(put_file, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL, HTTP_DEFAULT_STREAM_CONTEXT); - if (stream && !php_stream_stat(stream, &ssb)) { + if (stream && SUCCESS == php_stream_stat(stream, &ssb)) { obj->request->body = http_request_body_init_ex(obj->request->body, HTTP_REQUEST_BODY_UPLOADFILE, stream, ssb.sb.st_size, 1); } else { status = FAILURE; } + } else { + zval *put_data = GET_PROP(putData); + obj->request->body = http_request_body_init_ex(obj->request->body, HTTP_REQUEST_BODY_CSTRING, + estrndup(Z_STRVAL_P(put_data), Z_STRLEN_P(put_data)), Z_STRLEN_P(put_data), 1); } break; }