public function apply(HttpAdapter $http = null)
    {
        # For ease of use, we allow calling this method without an adapter,
        # which will cause the headers to be sent with PHP's global methods.
        if (is_null($http))
        {
            $http = new GlobalHttpAdapter();
        }

        $headers = $http->getHeaders();

        foreach ($this->pipeline() as $operation)
        {
            $operation->modify($headers);

            if ($operation instanceof ExposesErrors)
            {
                $this->errors = array_merge(
                    $this->errors,
                    $operation->collectErrors()
                );
            }
        }

        $http->sendHeaders($headers);

        $this->reportMissingHeaders($headers);
        $this->validateHeaders($headers);
        $this->reportErrors();

        return $headers;
    }