New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace Bleed #162

Open
PatrickRose opened this Issue Aug 19, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@PatrickRose

PatrickRose commented Aug 19, 2014

The toolbar bleeds 8 new lines into each response, which can cause issues (if, for example, you try and build a zip file then those 8 new lines will be included in that zip file causing it to be invalid).

Could this be fixed?

@Ocramius

This comment has been minimized.

Show comment
Hide comment
@Ocramius

Ocramius Aug 19, 2014

Member

@PatrickRose the toolbar should only interfere when the output is text/html. Could you elaborate a bit on this issue?

Member

Ocramius commented Aug 19, 2014

@PatrickRose the toolbar should only interfere when the output is text/html. Could you elaborate a bit on this issue?

@PatrickRose

This comment has been minimized.

Show comment
Hide comment
@PatrickRose

PatrickRose Aug 20, 2014

I'd need to delve deep into our source code to try and find the issue involved with download (though I'll grab the person involved when they come in).

I can spot it in our API requests though, and although it's not a real issue there it does irk me slightly.

PatrickRose commented Aug 20, 2014

I'd need to delve deep into our source code to try and find the issue involved with download (though I'll grab the person involved when they come in).

I can spot it in our API requests though, and although it's not a real issue there it does irk me slightly.

@PatrickRose

This comment has been minimized.

Show comment
Hide comment
@PatrickRose

PatrickRose Aug 21, 2014

Our download action uses the Zend\Http\Response\Stream object to stream the contents of the file, and we set the Content-Type to application/x-gzip.

PatrickRose commented Aug 21, 2014

Our download action uses the Zend\Http\Response\Stream object to stream the contents of the file, and we set the Content-Type to application/x-gzip.

@moderndeveloperllc

This comment has been minimized.

Show comment
Hide comment
@moderndeveloperllc

moderndeveloperllc Jan 9, 2015

Contributor

@PatrickRose Any update on this?

Contributor

moderndeveloperllc commented Jan 9, 2015

@PatrickRose Any update on this?

@PatrickRose

This comment has been minimized.

Show comment
Hide comment
@PatrickRose

PatrickRose Jan 9, 2015

I no longer work at the place where I encountered - but a message to the staff there says its still an issue.

PatrickRose commented Jan 9, 2015

I no longer work at the place where I encountered - but a message to the staff there says its still an issue.

@Barbarrosa

This comment has been minimized.

Show comment
Hide comment
@Barbarrosa

Barbarrosa Feb 23, 2015

Just downloading the ZF2 application skeleton and adding a download action to the index controller w/ the mentioned stream and type isn't enough to reproduce the issue. I had Zend Developer Tools installed via Composer and in the application config.

    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'Application',
        'ZendDeveloperTools',
    ),

Here's the code I used when I attempted to reproduce this issue.

    public function downloadAction()
    {
        $fileName = '/vagrant/somefile.tar.gz';
        $basename = basename($fileName);

        $response = new Stream();
        $response->setStream(fopen($fileName, 'r'));
        $response->setStatusCode(200);
        $response->setStreamName($basename);

        $headers = new Headers();
        $headers->addHeaders(array(
            'Content-Disposition' => 'attachment; filename="' . $basename . '"',
            'Content-Type' => 'application/x-gzip',
            'Content-Length' => filesize($fileName),
        ));
        $response->setHeaders($headers);
        return $response;
    }

I managed to download a working .tar.gz file. When I tested it using the answers in this StackOverflow question and compared it with various header parameters, the file still appeared to be fine when the Content-Disposition parameter was properly specified.

Barbarrosa commented Feb 23, 2015

Just downloading the ZF2 application skeleton and adding a download action to the index controller w/ the mentioned stream and type isn't enough to reproduce the issue. I had Zend Developer Tools installed via Composer and in the application config.

    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'Application',
        'ZendDeveloperTools',
    ),

Here's the code I used when I attempted to reproduce this issue.

    public function downloadAction()
    {
        $fileName = '/vagrant/somefile.tar.gz';
        $basename = basename($fileName);

        $response = new Stream();
        $response->setStream(fopen($fileName, 'r'));
        $response->setStatusCode(200);
        $response->setStreamName($basename);

        $headers = new Headers();
        $headers->addHeaders(array(
            'Content-Disposition' => 'attachment; filename="' . $basename . '"',
            'Content-Type' => 'application/x-gzip',
            'Content-Length' => filesize($fileName),
        ));
        $response->setHeaders($headers);
        return $response;
    }

I managed to download a working .tar.gz file. When I tested it using the answers in this StackOverflow question and compared it with various header parameters, the file still appeared to be fine when the Content-Disposition parameter was properly specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment