lib/Doctrine/CouchDB/HTTP/MultipartParserAndSender.php
public function request(
        $sourceMethod,
        $sourcePath,
        $targetPath,
        $sourceData = null,
        array $sourceHeaders = []
    ) {
        $this->sourceConnection = $this->sourceClient->getConnection(
            $sourceMethod,
            $sourcePath,
            $sourceData,
            $sourceHeaders
        );
        $sourceResponseHeaders = $this->sourceClient->getStreamHeaders();
        $body = '';

        if (empty($sourceResponseHeaders['status'])) {
            try {
                // Close the connection resource.
                fclose($this->sourceConnection);
            } catch (\Exception $e) {
            }
            throw HTTPException::readFailure(
                $this->sourceClient->getOptions()['ip'],
                $this->sourceClient->getOptions()['port'],
                'Received an empty response or not status code',
                0
            );
        } elseif ($sourceResponseHeaders['status'] != 200) {
            while (!feof($this->sourceConnection)) {
                $body .= fgets($this->sourceConnection);
            }
            try {
                fclose($this->sourceConnection);
            } catch (\Exception $e) {
            }

            return new ErrorResponse(
                $sourceResponseHeaders['status'],
                $sourceResponseHeaders,
                $body
            );
        } else {
            try {
                // Body is an array containing:
                // 1) Array of json string documents that don't have
                //  attachments. These should be posted using the Bulk API.
                // 2) Responses of posting docs with attachments.
                $body = $this->parseAndSend($targetPath);
                try {
                    fclose($this->sourceConnection);
                } catch (\Exception $e) {
                }

                return $body;
            } catch (\Exception $e) {
                throw $e;
            }
        }
    }
public function request(
        $sourceMethod,
        $sourcePath,
        $targetPath,
        $sourceData = null,
        array $sourceHeaders = []
    ) {
        $this->sourceConnection = $this->sourceClient->getConnection(
            $sourceMethod,
            $sourcePath,
            $sourceData,
            $sourceHeaders
        );
        $sourceResponseHeaders = $this->sourceClient->getStreamHeaders();
        $body = '';

        if (empty($sourceResponseHeaders['status'])) {
            try {
                // Close the connection resource.
                fclose($this->sourceConnection);
            } catch (\Exception $e) {
            }
            throw HTTPException::readFailure(
                $this->sourceClient->getOptions()['ip'],
                $this->sourceClient->getOptions()['port'],
                'Received an empty response or not status code',
                0
            );
        } elseif ($sourceResponseHeaders['status'] != 200) {
            while (!feof($this->sourceConnection)) {
                $body .= fgets($this->sourceConnection);
            }
            try {
                fclose($this->sourceConnection);
            } catch (\Exception $e) {
            }

            return new ErrorResponse(
                $sourceResponseHeaders['status'],
                $sourceResponseHeaders,
                $body
            );
        } else {
            try {
                // Body is an array containing:
                // 1) Array of json string documents that don't have
                //  attachments. These should be posted using the Bulk API.
                // 2) Responses of posting docs with attachments.
                $body = $this->parseAndSend($targetPath);
                try {
                    fclose($this->sourceConnection);
                } catch (\Exception $e) {
                }

                return $body;
            } catch (\Exception $e) {
                throw $e;
            }
        }
    }
public function request ( $ sourceMethod , $ sourcePath , $ targetPath , $ sourceData = null , array $ sourceHeaders = [ ] ) { $ this -> sourceConnection = $ this -> sourceClient -> getConnection ( $ sourceMethod , $ sourcePath , $ sourceData , $ sourceHeaders ) ; $ sourceResponseHeaders = $ this -> sourceClient -> getStreamHeaders ( ) ; $ body = '' ; if ( empty ( $ sourceResponseHeaders [ 'status' ] ) ) { try { // Close the connection resource. fclose ( $ this -> sourceConnection ) ; } catch ( \ Exception $ e ) { } throw HTTPException :: readFailure ( $ this -> sourceClient -> getOptions ( ) [ 'ip' ] , $ this -> sourceClient -> getOptions ( ) [ 'port' ] , 'Received an empty response or not status code' , 0 ) ; } elseif ( $ sourceResponseHeaders [ 'status' ] != 200 ) { while ( ! feof ( $ this -> sourceConnection ) ) { $ body .= fgets ( $ this -> sourceConnection ) ; } try { fclose ( $ this -> sourceConnection ) ; } catch ( \ Exception $ e ) { } return new ErrorResponse ( $ sourceResponseHeaders [ 'status' ] , $ sourceResponseHeaders , $ body ) ; } else { try { // Body is an array containing: // 1) Array of json string documents that don't have //  attachments. These should be posted using the Bulk API. // 2) Responses of posting docs with attachments. $ body = $ this -> parseAndSend ( $ targetPath ) ; try { fclose ( $ this -> sourceConnection ) ; } catch ( \ Exception $ e ) { } return $ body ; } catch ( \ Exception $ e ) { throw $ e ; } } }
Perform request to the source, parse the multipart response,
stream the documents with attachments to the target and return
the responses along with docs that did not have any attachments.

@param string $sourceMethod
@param string $sourcePath
@param string $targetPath
@param string $sourceData
@param array  $sourceHeaders

@throws HTTPException
@throws \Exception

@return array|ErrorResponse|string
Perform request to the source parse the multipart response stream the documents with attachments to the target and return the responses along with docs that did not have any attachments .