gruntjs / grunt-contrib-connect

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

Jar file returns with invalid length (Corrupted jar file returned) #136

Closed shuk closed 6 years ago

shuk commented 10 years ago

Some .jar files returns with incorrect length so returned .jar files are corrupted.

E.g. I hosted httpcore-4.2.1.jar as static content. The actual size is 223374 bytes http://central.maven.org/maven2/org/apache/httpcomponents/httpcore/4.2.1/httpcore-4.2.1.jar

But "grunt connect" returned httpcore-4.2.1.jar file as file with length 389046 bytes (corrupted file)!

On my local computer the jar file was located here: \web\plugins\scan-tool\lib\resteasy\httpcore-4.2.1.jar

And for hosting I used following code:

connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('web')
                        ];
                    }
                }
            }
        },
misja-alma commented 10 years ago

This looks like the issue I'm having (issue #145). Check the file encoding of the corrupted jar. In my case it was updated to UTF-8, which explains why the file has grown in size (and why it has become corrupted).

koolshams commented 8 years ago

Looks like this is an issue related to connect-livereload plugin.

this plugin will try to encode response content as a string, to see whether it is html content. if not it sends the encoded string as response which will corrupt the binary files.

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

As a workaround find connect-livereload/index.js in node_modules find the following function

function livereload(req, res, next) {

Add some logic so that your URL is not checked. Also you can add .jar pattern in ignore list.

But there is no correct solution as there are lot more other this depends on this feature.

XhmikosR commented 6 years ago

Seems an upstream issue.