Giter Site home page Giter Site logo

Comments (11)

dougwilson avatar dougwilson commented on March 29, 2024

Hi! This module is a no-op on HEAD requests--we even have a test for this: https://github.com/expressjs/compression/blob/master/test/test.js#L22

Please let me know what version of this module you are using, what version of Node.js and a full reproducable test case (you can always edit our test file if you're not sure how to provide a test case).

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

From your stack trace, if you really did get a HEAD request, you may want to verify something in your code base did not lower-casereq.method value--it is only valid to be upper-case. The reason I say this is because your stack trace includes Express render -> send calls and those are operating as if it's not a HEAD request, just like this module is.

from compression.

mingoing avatar mingoing commented on March 29, 2024

I create a test repo https://github.com/wlsy/compressionTest.git
npm install & npm start &node testHEAD.js

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

I'm sorry, it doesn't reproduce for me:

Doug.wilson@IN5358 ~/test
$ git clone https://github.com/wlsy/compressionTest.git
Cloning into 'compressionTest'...
remote: Counting objects: 23, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 23 (delta 1), reused 23 (delta 1)
Unpacking objects: 100% (23/23), done.
Checking connectivity... done

Doug.wilson@IN5358 ~/test
$ cd compressionTest/

Doug.wilson@IN5358 ~/test/compressionTest (master)
$ npm install
[email protected] node_modules\cookie-parser
├── [email protected]
└── [email protected]

[email protected] node_modules\debug
└── [email protected]

[email protected] node_modules\morgan
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

[email protected] node_modules\serve-favicon
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

[email protected] node_modules\compression
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])

[email protected] node_modules\body-parser
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

[email protected] node_modules\request
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

[email protected] node_modules\express
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected])

[email protected] node_modules\jade
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

Doug.wilson@IN5358 ~/test/compressionTest (master)
$ node testHEAD.js
head request done

Doug.wilson@IN5358 ~/test/compressionTest (master)
$ node -v
v0.11.14

And the window with the server running:

Doug.wilson@IN5358 ~/test/compressionTest (master)
$ npm start

> [email protected] start c:\Users\doug.wilson\test\compressionTest
> node ./bin/www

HEAD / 200 622.418 ms - 170

from compression.

mingoing avatar mingoing commented on March 29, 2024

I think it might be a bug on node 0.11.14, using 0.10 will be ok.

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

As you can see in my logs above, I used 0.11.14, not 0.10.

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

I had looked at it more since I posted me running your app on Node.js 0.11.14 above, and I haven't been able to reproduce the issue (yes, even on 0.11.14). Can you try a few things?

  1. Completely uninstall your Node.js 0.11.14 and reinstall it. Perhaps you have a messed up version or something?
  2. Try to reproduce it on a completely different machine with your repo.
  3. Use the official binary from Node.js: http://nodejs.org/dist/v0.11.14/ and see if it still happens.

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

@wlsy I can reproduce it now. This is the reason I could not before: nodejs/node-v0.x-archive#8855

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

Root issue is an Express 4.x bug. Follow along at expressjs/express#2467 :)

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

There is also a change I'm going to make to this module that will also fit more in line with 0.11.14 changes.

from compression.

dougwilson avatar dougwilson commented on March 29, 2024

If you now upgrade to [email protected], you'll avoid the bug in Express and your code will no longer error.

from compression.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.