Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Support file stream #4897

Closed

Conversation

ClemensSahs
Copy link
Contributor

hallo I think I found a forgotten code area ;)

near this line

if we have a file resource, the CURL adapter try to get the file size from the header "content-lenght".

we have on the $headers var a array like this

array(7) {
  ["Host"]=>
  string(14) "127.0.0.1:5984"
  ["Connection"]=>
  string(5) "close"
  ["Accept-Encoding"]=>
  string(13) "gzip, deflate"
  ["User-Agent"]=>
  string(16) "Zend\Http\Client"
  ["Content-Type"]=>
  string(16) "application/json"
  ["Content-Length"]=>
  string(2) "26"
  ["content-type"]=>
  string(16) "application/json"
}

but he try it detect form the value with preg_match()

foreach ($headers AS $k => $header) {
    if (preg_match('/Content-Length:\s*(\d+)/i', $header, $m)) {
        if (is_resource($body)) {
            $this->config['curloptions'][CURLOPT_INFILESIZE] = (int) $m[1];
        }
    unset($headers[$k]);
    }
}

If the old code has a reason so correct me

best regards

we have here the array index "Content-Length" and a value typed integer
weierophinney added a commit that referenced this pull request Aug 19, 2013
- If the CURLOPT_INFILESIZE option *is* available, but no content-length
  header is sent, we can proceed. Only reset the CURLOPT_INFILESIZE if
  the content-length header is present.
weierophinney added a commit that referenced this pull request Aug 19, 2013
@weierophinney
Copy link
Member

Cherry-picked to master for release with 2.2.3.

@ghost ghost assigned weierophinney Aug 19, 2013
@ClemensSahs ClemensSahs deleted the supportFileStream branch October 18, 2013 07:34
weierophinney added a commit to zendframework/zend-http that referenced this pull request May 15, 2015
- If the CURLOPT_INFILESIZE option *is* available, but no content-length
  header is sent, we can proceed. Only reset the CURLOPT_INFILESIZE if
  the content-length header is present.
weierophinney added a commit to zendframework/zend-http that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-http that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants