classes/phing/tasks/ext/HttpGetTask.php
protected function processResponse(HTTP_Request2_Response $response)
    {
        if ($response->getStatus() != 200) {
            throw new BuildException(
                "Request unsuccessful. Response from server: " . $response->getStatus()
                . " " . $response->getReasonPhrase(),
                $this->getLocation()
            );
        }

        $content = $response->getBody();
        $disposition = $response->getHeader('content-disposition');

        if ($this->filename) {
            $filename = $this->filename;
        } elseif ($disposition && 0 == strpos($disposition, 'attachment')
            && preg_match('/filename="([^"]+)"/', $disposition, $m)
        ) {
            $filename = basename($m[1]);
        } else {
            $filename = basename(parse_url($this->url, PHP_URL_PATH));
        }

        if (!is_writable($this->dir)) {
            throw new BuildException("Cannot write to directory: " . $this->dir, $this->getLocation());
        }

        $filename = $this->dir . "/" . $filename;
        file_put_contents($filename, $content);

        $this->log("Contents from " . $this->url . " saved to $filename");
    }
protected function processResponse(HTTP_Request2_Response $response)
    {
        if ($response->getStatus() != 200) {
            throw new BuildException(
                "Request unsuccessful. Response from server: " . $response->getStatus()
                . " " . $response->getReasonPhrase(),
                $this->getLocation()
            );
        }

        $content = $response->getBody();
        $disposition = $response->getHeader('content-disposition');

        if ($this->filename) {
            $filename = $this->filename;
        } elseif ($disposition && 0 == strpos($disposition, 'attachment')
            && preg_match('/filename="([^"]+)"/', $disposition, $m)
        ) {
            $filename = basename($m[1]);
        } else {
            $filename = basename(parse_url($this->url, PHP_URL_PATH));
        }

        if (!is_writable($this->dir)) {
            throw new BuildException("Cannot write to directory: " . $this->dir, $this->getLocation());
        }

        $filename = $this->dir . "/" . $filename;
        file_put_contents($filename, $content);

        $this->log("Contents from " . $this->url . " saved to $filename");
    }
protected function processResponse ( HTTP_Request2_Response $ response ) { if ( $ response -> getStatus ( ) != 200 ) { throw new BuildException ( "Request unsuccessful. Response from server: " . $ response -> getStatus ( ) . " " . $ response -> getReasonPhrase ( ) , $ this -> getLocation ( ) ) ; } $ content = $ response -> getBody ( ) ; $ disposition = $ response -> getHeader ( 'content-disposition' ) ; if ( $ this -> filename ) { $ filename = $ this -> filename ; } elseif ( $ disposition && 0 == strpos ( $ disposition , 'attachment' ) && preg_match ( '/filename="([^"]+)"/' , $ disposition , $ m ) ) { $ filename = basename ( $ m [ 1 ] ) ; } else { $ filename = basename ( parse_url ( $ this -> url , PHP_URL_PATH ) ) ; } if ( ! is_writable ( $ this -> dir ) ) { throw new BuildException ( "Cannot write to directory: " . $ this -> dir , $ this -> getLocation ( ) ) ; } $ filename = $ this -> dir . "/" . $ filename ; file_put_contents ( $ filename , $ content ) ; $ this -> log ( "Contents from " . $ this -> url . " saved to $filename" ) ; }
Saves the response body to a specified directory

@param  HTTP_Request2_Response $response
@return void
@throws BuildException
Saves the response body to a specified directory