/** * @param Swift_OutputByteStream $fromStream * @param Swift_InputByteStream $toStream */ protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) { $bufferLength = 4096; $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); while (false !== ($buffer = $fromStream->read($bufferLength))) { $filteredStream->write($buffer); } $filteredStream->flushBuffers(); while (false !== ($buffer = $filteredStream->read($bufferLength))) { $toStream->write($buffer); } $toStream->commit(); }
/** * Write this entire entity to a {@see Swift_InputByteStream}. * * @param Swift_InputByteStream */ public function toByteStream(Swift_InputByteStream $is) { $is->write($this->_headers->toString()); $is->commit(); $this->_bodyToByteStream($is); }
/** * Write this entire entity to a {@see Swift_InputByteStream}. * * @param Swift_InputByteStream */ public function toByteStream(Swift_InputByteStream $is) { $is->write($this->_headers->toString()); $is->commit(); if (empty($this->_immediateChildren)) { if (isset($this->_body)) { if ($this->_cache->hasKey($this->_cacheKey, 'body')) { $this->_cache->exportToByteStream($this->_cacheKey, 'body', $is); } else { $cacheIs = $this->_cache->getInputByteStream($this->_cacheKey, 'body'); if ($cacheIs) { $is->bind($cacheIs); } $is->write("\r\n"); if ($this->_body instanceof Swift_OutputByteStream) { $this->_body->setReadPointer(0); $this->_encoder->encodeByteStream($this->_body, $is, 0, $this->getMaxLineLength()); } else { $is->write($this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); } if ($cacheIs) { $is->unbind($cacheIs); } } } } if (!empty($this->_immediateChildren)) { foreach ($this->_immediateChildren as $child) { $is->write("\r\n\r\n--" . $this->getBoundary() . "\r\n"); $child->toByteStream($is); } $is->write("\r\n\r\n--" . $this->getBoundary() . "--\r\n"); } }