Content-Length header is wrong #6

Closed
opened 2012-03-01 10:16:39 +00:00 by der-flo · 5 comments
der-flo commented 2012-03-01 10:16:39 +00:00 (Migrated from github.com)

I'm getting an error from Rack::Lint:

ERROR Rack::Lint::LintError: Content-Length header was 599, but should be 261

My simple rackup file contains:

require 'rubygems'
require 'bundler/setup'
require 'rack-livereload'

use Rack::LiveReload
run Rack::Directory.new('.')

What I'm doing wrong? Do I misunderstand the middleware concept?

I'm getting an error from Rack::Lint: ``` ERROR Rack::Lint::LintError: Content-Length header was 599, but should be 261 ``` My simple rackup file contains: ``` ruby require 'rubygems' require 'bundler/setup' require 'rack-livereload' use Rack::LiveReload run Rack::Directory.new('.') ``` What I'm doing wrong? Do I misunderstand the middleware concept?
johnbintz commented 2012-03-01 14:11:43 +00:00 (Migrated from github.com)

Do you get the same error with a basic Rack app, like say:

run lambda { |env| [ 200, {}, [ 'hi' ] ] }
Do you get the same error with a basic Rack app, like say: ``` ruby run lambda { |env| [ 200, {}, [ 'hi' ] ] } ```
der-flo commented 2012-03-02 08:58:02 +00:00 (Migrated from github.com)

Your sample misses a content type. The following works:

use Rack::LiveReload
run lambda { |env| [ 200, { 'Content-Type' => 'text/html' }, [ '<html><head></head><body>hi</body></html>' ] ] }

I (think that I) need Rack::Directory for reloading my static HTML files for a live HTML course. Other suggestions?

BTW: I think the difference in content length results from adding the js script tags.

Your sample misses a content type. The following works: ``` ruby use Rack::LiveReload run lambda { |env| [ 200, { 'Content-Type' => 'text/html' }, [ '<html><head></head><body>hi</body></html>' ] ] } ``` I (think that I) need `Rack::Directory` for reloading my static HTML files for a live HTML course. Other suggestions? BTW: I think the difference in content length results from adding the js script tags.
afiore commented 2012-03-02 11:05:23 +00:00 (Migrated from github.com)

Same problem here, I get the following message in the web server log:

!!Unexpected error while processing request: Content-Length header was 2175, but should be 1837
Same problem here, I get the following message in the web server log: ``` !!Unexpected error while processing request: Content-Length header was 2175, but should be 1837 ```
johnbintz commented 2012-03-02 14:27:59 +00:00 (Migrated from github.com)

I was making a bad assumption about the returns from Rack apps, and that is now fixed. Take it for a spin.

I was making a bad assumption about the returns from Rack apps, and that is now fixed. Take it for a spin.
der-flo commented 2012-03-05 08:07:54 +00:00 (Migrated from github.com)

Jep, works perfectly!

Jep, works perfectly!
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: github-migration/rack-livereload#6
No description provided.