Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94121 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25021 invoked from network); 19 Jun 2016 14:36:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jun 2016 14:36:49 -0000 Authentication-Results: pb1.pair.com header.from=irker@irker.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=irker@irker.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain irker.net from 209.85.215.44 cause and error) X-PHP-List-Original-Sender: irker@irker.net X-Host-Fingerprint: 209.85.215.44 mail-lf0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:35722] helo=mail-lf0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/3B-18862-FFDA6675 for ; Sun, 19 Jun 2016 10:36:48 -0400 Received: by mail-lf0-f44.google.com with SMTP id l188so23602857lfe.2 for ; Sun, 19 Jun 2016 07:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irker-net.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=nOQNqKU4LCaCjwU6h2ivW4S8pgqzC54kobTelpMWb+E=; b=ge6i57brlDGxjQeuKbZEPmOvNxoQgIv3Yk2f2WkH7k1Nl197sDvsxDv++Q/KuzKFJX cQ/0dud/0qEMh2Ve5hEzp28/xMhQWuxceg22KwJVKhtN/g6ss3UC1QoW1dTnlwiRZ4bG TCJJx/Ue1fxTTHeYkLMH8vm4L3hQgjrAfMjSIGbhSexvsm7NqtTXajCA/ddrSDc0y7T7 mRywtY9JEL/G48ml3tfyNEzRsCAO6hdeltWtfWIt4T+pJydp3ICvoipaIAmKdu7z4n+P oesJa5QRfts6Bp6tWBwfdt8IF6R75v9XX0xDbm8S9uP0G0aDhEdPIF5+h4go1dlT2SDH HTpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nOQNqKU4LCaCjwU6h2ivW4S8pgqzC54kobTelpMWb+E=; b=C07vzdZ1PknvqeaeLTwLuAJzp13RkiWIE0T1S1yBTvC7qVPXxD+XI/oxe7JOjei35y wC7IRCHUAndBdmaZXaBp5NtPDUYw9XDN8OHkn3CsiSqaKiq8alKXvVQuCoP5RSjAnzSo Criv0PrO4DDnXbWgaJkf/0fTIUEJAjlXeDyt802Qk+Yul2POvmRpYRBM/zxgdp9ftr5s 20fmjxPfnuw3Dg7MXJ7ParKVo0TyVpfbefFKZVEDpYN7s1AhEjbRzGWj9aMLbKlfLdYb O/9aB8d919UfoN8wuUeXs2yJRH9cfI7vvSWMX6P0D32vZeZOVl/zp8nACWyDG88yd6E6 Y/HQ== X-Gm-Message-State: ALyK8tJHBC9EbQ0/nnk/ZX2Cs0SDhV1MkgRrtRVCDu8u3tECTQi44P+cMJyN9sjpGWPQob0uHEGMsPVNhZMoGA== X-Received: by 10.25.38.213 with SMTP id m204mr550398lfm.107.1466347004574; Sun, 19 Jun 2016 07:36:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.209.204 with HTTP; Sun, 19 Jun 2016 07:36:24 -0700 (PDT) Date: Sun, 19 Jun 2016 17:36:24 +0300 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11403d04534e420535a28455 Subject: Send files in CURL from string From: irker@irker.net (Alexander Moskalev) --001a11403d04534e420535a28455 Content-Type: text/plain; charset=UTF-8 Hello! I have idea to make possible to send files with CURL from string. CURL library has few options to make it as easy as possible: CURLFORM_BUFFER, CURLFORM_BUFFERPTR, and CURLFORM_BUFFERLENGTH. But I got many problems with integration of this feature in current php curl file attachment design. Class CURLFile has one required $filename property, and two optional properties $mimetype and $postname. In my case we need two required properties $buffer and $postname, and one optional $mimetype. Also we have function curl_file_create, which just like alias function for CURLFile constructor with same arguments. So I tried to implement feature by different ways: 1) Create new class CURLFileBuffer by simple copy-paste code from CURLFile. (pull-request https://github.com/php/php-src/pull/1217 - code was removed, sorry) positive: - No BC break - API similar to CURLFile negative: - A lot of code duplication, hard to support in future. Thanks to Tony2001 and S.Malyshev for reviewing. 2) Integrate new feature to exists CURLFile class. (pull-request https://github.com/php/php-src/pull/1283) positive: - One class for new and old features - No code duplication - No BC break (* except some little not obviously cases) negative: - Not clear behavior if developer will set $filename and $buffer in same time. It require more documentation and not obviously for developers. - Not clear which values of $filename we must ignore to start use $buffer. - etc. Thanks to S.Malyshev for reviewing. 3) Like #2, but make CURLFile immutable after instance creation by curl_file_create and curl_file_buffer_create functions (or by little modified constructors). positive: - Clear behavior. negative: - Great BC break: CURLFile has public properties and setters methods. I like it, I think it will be great to make CURLFile immutable, but I'm sure no one want such BC. =( 4) Like #1, but move code duplication to common C code, used by two classes. It's impossible, because this classes so simple, so 95% of code like that: > /* {{{ proto string CURLFile::getFilename() Get file name */ ZEND_METHOD(CURLFile, getFilename) { curlfile_get_property("name", INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ So both classes required such doc block ({{{ proto ...) and call *_property methods. 5) Like #1, but move code duplication to abstract class, for example CURLFileAbstract. So we move $mimetype and $postname to abstract class, $filename to CURLFile, $buffer to CURLFileBuffer class. They will have own constructors with own arguments requiring. positive: - No BC break - less code duplication negative: - new abstract class, used ONLY for less code duplication in curl extension, it has no sense for developers. 6+) Your variant, please provide it. As you can see, so little change, like using few simple options from curl library, require so long mail, few pull-requests and too many time from internal php people. But I believe, we can do it. Thank you, and please help me to finish this small feature. -- With regards, Alexander Moskalev irker@irker.net irker@php.net a.moskalev@corp.badoo.com --001a11403d04534e420535a28455--