Merge two response.

@param DownstreamResponse $response
546873
public function merge(DownstreamResponse $response)
    {
        $this->numberTokensSuccess += $response->numberSuccess();
        $this->numberTokensFailure += $response->numberFailure();
        $this->numberTokenModify += $response->numberModification();

        $this->tokensToDelete = array_merge($this->tokensToDelete, $response->tokensToDelete());
        $this->tokensToModify = array_merge($this->tokensToModify, $response->tokensToModify());
        $this->tokensToRetry = array_merge($this->tokensToRetry, $response->tokensToRetry());
        $this->tokensWithError = array_merge($this->tokensWithError, $response->tokensWithError());
    }
629350
protected function interactsWithResponse(Response $response): Response
    {
        if ($response instanceof Filterable && $this instanceof Filterable) {
            $response->setFilterable($this->getFilterable());
        }

        if ($this->validateResponseAutomatically === true) {
            $response->validate();
        }

        return $response;
    }
1113435
protected function splitResponseToHeadersArrayAndBody(string $response): HttpResponseInterface
    {
        //        $tmp = explode("\r\n\r\n", $response, 2);
        //        var_export($tmp);
        list($headers, $this->body) = explode("\r\n\r\n", $response, 2);

        $this->headers = $this->getHeaderArray($headers);

        return $this;
    }
791830
public function set($response, $replaceResponse = false)
    {
        if ($replaceResponse) {
            $this->response = $response;
        } else {
            $this->response = array_merge($this->response, $response);
        }
    }
772930
protected function processResult(Response $response)
    {
        $content = $response->getContent();
        if (strpos($content, "callback(") === 0) {
            $count = 0;
            $jsonData = preg_replace('/^callback\(\s*(\\{.*\\})\s*\);$/is', '\1', $content, 1, $count);
            if ($count === 1) {
                $response->setContent($jsonData);
            }
        }
    }
336647
public function sendResponse($response)
    {
        // clean any previous output from buffer. Not effective in some cases
        while (ob_get_level() > 0) {
            ob_end_clean();
        }

        // console //

        if ($response instanceof ConsoleResponse) {
            echo $response->getContent();
            $errorLevel = (int) $response->getErrorLevel();
            exit($errorLevel);
        }


        // http //

        // send headers
        foreach ($response->getHeaders() as $header) {
            header($header->toString());
        }

        // send status
        $status = $response->renderStatusLine();
        header($status);

        // send content
        echo $response->getContent();
        exit(1);
    }
375583
public function respond($response = array(), $replaceResponse = false)
    {
        // Set any final data
        $this->set($response, $replaceResponse);

        // Make sure it only responds once
        if ($this->hasResponded()) {
            return;
        }

        // Clear anything that may have snuck in
        $this->cleanBuffer();

        if (self::$code == 204) {
            // No-body response
            $this->responseSent = true;
            return;
        }

        if (!empty($this->apiResponseCallback) && is_callable($this->apiResponseCallback)) {
            $callback = &$this->apiResponseCallback;
            $callback($this->response);
        }

        // Format for specific output type
        if ($this->responseFormat == 'JSON') {
            if ($this->jsonCallbackWrap) {
                echo $this->jsonCallbackWrap . '(';
            }

            echo json_encode($this->response);

            if ($this->jsonCallbackWrap) {
                echo ');';
            }
        } else {
            throw new \Exception('Invalid response format: '. $this->responseFormat);
        }

        // Indicate the response as already sent
        $this->responseSent = true;
    }
1358918
private function _parseResponse(Response $response)
    {
        switch ($this->_format) {
            case self::FORMAT_JSON:
                return json_decode($response, $this->_isJsonDecodeAssoc);
                break;
            default:
                return $response;
        }
    }
335999
protected function bbserver_recombine_response( $response ) {
		if ( $this->validate_response( $response ) ) {
			return $response;
		}
		$remote_info_file = '';
		if ( isset( $response->lines ) ) {
			foreach ( (array) $response->lines as $line ) {
				$remote_info_file .= $line->text . "\n";
			}
		}

		return $remote_info_file;
	}
232376
public function prepareForResponse(Response $response) {
		if ('application/json' == $response->getRequest()->getAcceptRange()
	               ->bestMatch(['text/html', 'application/json'])) {
            	$this->payload = new JhtmlJsonPayload($this->additionalAttrs);
               	$this->payload->applyRedirect($this->directive, $this->httpLocation, $this->jhtmlExec);
			$this->payload->prepareForResponse($response);
	        return;
	    } 
	    
		$this->payload = new Redirect($this->httpLocation);
		$this->payload->prepareForResponse($response);
	}
847398
protected function sendHeaders(Response $response)
    {
        // Send HTTP status & reason-phrase
        header(
            sprintf(
                '%s %s %s',
                $this->getProtocolLine(),
                $response->getStatusCode(),
                $response->getReasonPhrase()
            ),
            true,
            $response->getStatusCode()
        );

        // Send headers
        $headers = $response->getHeaders();
        foreach ($headers as $name => $valueCollection) {
            foreach ($valueCollection as $value) {
                header(sprintf('%s: %s', $name, $value), false);
            }
        }
    }
991517
private function processResponse(Response $response)
    {
        $response = $response->getBody()->getContents();
        $response = json_decode($response, true);

        return $response;
    }
354767
protected function appendAllResponse(ResponseInterface $response): ResponseInterface
    {
        if ($this->append) {
            $this->cors->setResponse('psr-7', $response);
            $this->cors->handle();

            return $this->cors->getResponse();
        }

        return $response;
    }
1213167
private function loadResponse_v2($response) {
		// Set global Status-Values first
		if(isset($response->Status)) {
			if(isset($response->Status->statusCode))
				$this->setStatusCode((int) $response->Status->statusCode);
			if(isset($response->Status->statusText)) {
				if(is_array($response->Status->statusText))
					$this->setStatusText(implode(';', $response->Status->statusText));
				else
					$this->setStatusText($response->Status->statusText);
			}
			if(isset($response->Status->statusMessage)) {
				if(is_array($response->Status->statusMessage))
					$this->setStatusMessage(implode(';', $response->Status->statusMessage));
				else
					$this->setStatusMessage($response->Status->statusMessage);
			}
		}

		// Set Manifest if exists (getManifest)
		if(isset($response->manifestData)) {
			$this->setManifestData($response->manifestData);

			return;
		}

		/*
		 * Handle Shipment(s) | Calls on:
		 * 1 -> createShipmentOrder
		 * 2 -> deleteShipmentOrder
		 * 3 -> updateShipmentOrder [Only Single]
		 * 3 -> getLabel
		 * 4 -> validateShipment
		 * 5 -> getExportDoc
		 * 6 -> doManifest
		 */
		if(isset($response->CreationState)) // 1
			$this->handleMultiShipments($response->CreationState);
		else if(isset($response->DeletionState)) // 2
			$this->handleMultiShipments($response->DeletionState);
		else if(isset($response->LabelData)) // 3
			$this->handleMultiShipments($response->LabelData);
		else if(isset($response->ValidationState)) // 4
			$this->handleMultiShipments($response->ValidationState);
		else if(isset($response->ExportDocData)) // 5
			$this->handleMultiShipments($response->ExportDocData);
		else if(isset($response->ManifestState)) // 6
			$this->handleMultiShipments($response->ManifestState);

		// Validate the status to fix errors on the Main-Status and show weak-warnings
		if($this->getStatusCode() !== self::DHL_ERROR_NOT_SET)
			$this->validateStatusCode();
	}
1122394
public function process(\BearFramework\App\Response $response): void
    {
        $response->content = $this->app->components->process($response->content);
    }
517003
protected function addHeaders(Response $response, $maxAttempts, $remainingAttempts, $retryAfter = null)
    {
        $headers = [
            'X-RateLimit-Limit' => $maxAttempts,
            'X-RateLimit-Remaining' => $remainingAttempts,
        ];

        if (!is_null($retryAfter)) {
            $headers['Retry-After'] = $retryAfter;
        }

        $response->headers->add($headers);

        return $response;
    }
628272
protected function finishRequest(Response $response)
    {
        $event = new FinishRequestEvent($this->app, $response);
        $this->event_dispatcher->dispatch(DietcubeEvents::FINISH_REQUEST, $event);

        $response = $event->getResponse();

        $response->sendHeaders();
        $response->sendBody();

        return $response;
    }