gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 145 forks source link

Serving binary files broken? #142

Open miminno opened 10 years ago

miminno commented 10 years ago

When using connect to serve binary files (pdf's) they show up in the browser as broken. The content length is reported wrong too (2.5Kb of the real file vs 3.9Kb in the browser).

misja-alma commented 10 years ago

Looks like the same issue I'm having (issue #145). The character encoding is somehow changed to UTF-8, which explains why the file has grown in size.

chrstr commented 9 years ago

Looks like this was broken recently. If I revert my dependency to 0.8.0 this is working again for me. It's broken on 0.9.0.

michi88 commented 9 years ago

0.8.0 is not working for me (at least together with https://github.com/drewzboto/grunt-connect-proxy)

This is the diff: https://github.com/gruntjs/grunt-contrib-connect/compare/31fb2b2010539d5718da6805b93473b5a79d084c...master#diff-d0f77dfe96c2eba118cfc72926282b01

I also don't see what changed that could have caused this.

pswai commented 9 years ago

Reverting to 0.8.0 works for me. In my case, I was having problem with loading applets.

eekboom commented 9 years ago

For me, too downgrading to 0.8.0 fixes the issue, too. Unfortunately I am much too busy with testing and release preparation for me to have a deeper look at the issue :-(

eekboom commented 9 years ago

Ok, after spending quite some time I found that the bug is in connect-livereload, and it is already known:

https://github.com/intesso/connect-livereload/issues/39

dkobozev commented 8 years ago

It does look like it's an issue with connect-livereload, but the thread linked by @eekboom mentions a workaround in the form of adding an ignore: ['.pdf'] option. I couldn't figure out how to pass that option to connect-livereload from my Gruntfile, so I had to disable livereloading completely.

treejanitor commented 8 years ago

I was actually able to do it in my express config... I'm using a reasonably new angular-fullstack version for the root of the grunt set up. For whatever reason, I didn't have to do it in my Gruntfile.

I'm not sure the disabling of compression is required, but I did it to as a way to make sure I could completely valid byte counts along the wire...

in my /server/config/express.js config set up using angular-fullstack

  if ('development' === env) {
    app.use(require('connect-livereload')({
      ignore: [/\.pdf(\?.*)?$/, /\.zip(\?.*)?$/],
      disableCompression: true
    }));
  }

Very very frustrating issue to debug, for me, anyway, particularly because zip files were not mentioned as issues in people's comments and they change size to begin with after compression.

bartolomeon commented 8 years ago

@dkobozev I made a fork of grunt-contrib-connect and added an option to pass the 'ignore' option from Gruntfile to connect-livereload. It is for a latest version thought. Here it is: https://github.com/bartolomeon/grunt-contrib-connect (updated the README.md as well). I'll make a PR for it, maybe it will get accepted :)

halfmatthalfcat commented 8 years ago

+1 this caused consistent CONTENT_MISMATCH_ERRORs in Chrome when livereload was used in middleware along with the mounted static files.