Comments (8)
Thanks for the report. I will try to reproduce and maybe narrow down to a specific new unit test. Would it be easy enough for you to also try this with sinatra 1.4.2, fishwife 1.4.0, jetty ~> 7.6.10? Also could you include the "jruby -v" line?
from fishwife.
I realized I have my own case of using sinatra and send_file and tested with an upgrade to sinatra 1.4.2 on that application. I don't see any random characters. Tested with these rubies:
jruby 1.6.8 (ruby-1.9.2-p312) (2012-09-18 1772b40) (Java HotSpot(TM) Server VM 1.7.0_21) [linux-i386-java]
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) Server VM 1.8.0-ea-b84 +indy [linux-i386]
And gems:
fishwife (1.5.0-java)
rack (1.5.2)
rack-protection (1.5.0)
rack-test (0.6.2)
rjack-jetty (9.0.2.0-java)
sinatra (1.4.2)
Note that fishwife does have a different java-optimized path for send_file than Mizuno, so a specific issue is plausible.
Is it a character encoding issue you are are seeing or something else? Perhaps you could minimize the test file and send me the full output with something like curl -i
?
from fishwife.
Hey, I'm using jruby 1.7.3 on osx and I'd be happy to help out testing of course. This issue had me puzzled quite a bit yesterday and I spent quite a bit of time narrowing it down. I'll try to create a test for this.
I think we're both using the latest gems of everything. I actually downgraded everything and then upgraded the gems one by one. Sinatra is the one that breaks it as of 1.4.0. Something changed in that release.
I don't think that it is an encoding issue. Even the string hello in a file index.html comes out mangled as '6 hello 0'. So there seems to be stuff appended and prepended. I'm seeing similar things with real html where some characters appear before the first tag and after the last one.
BTW. Github does not allow forks of forks, so I can't send you pull requests. I can email you a patch of course.
from fishwife.
I tried to integrate with your test suite but it seems to behave in a different way than simply running fishwife from the command line.
I have a very minimal sinatra application that fails:
config.ru
require 'testapp'
map '/' do
run StaticContentController
end
testapp
require 'sinatra'
class StaticContentController < Sinatra::Base
get '/' do
send_file '/Users/jilles/test/hello.html'
end
end
hello.html
hello
command line
$ gem uninstall sinatra; gem install --version '1.4.2' sinatra
$ fishwife &
$ curl http://localhost:9292/
6
hello0
$ gem uninstall sinatra; gem install --version '1.3.6' sinatra
$ fishwife &
$ curl http://localhost:9292/
hello
The same controller when connected to your test seems to work as expected so something is different there. I simply copied your spec file and made it load my controller instead of yours and then used your get function to get '/'. When I run that, everything seems as it should be.
from fishwife.
OK, thanks for the additional details, I can now reproduce your findings using a config.ru and standalone fishwife
or rackup
. What you are seeing is the application of chunked encoding by Rack::Chunked which is then effectively made "literal" by Jetty.
- sinatra 1.3.x would ignore/replace the middleware stack completely so this was never an issue. Sinatra 1.4 apparently has a fix to preserve the middleware stack including defaults from config.ru, and Rack::Server as in this case. You can see Rack::Chunked on the app stack via
fishwife -d
. - Mizuno includes a monkey-patch which disables Rack::Chunked in lib/mizuno/rack/chunked.rb. Given the ability to set proper middleware in my apps (via Sinatra 1.3 or by explicit control from not using config.ru, Rack::Server) I have been reluctant to include this hack. This report makes me reconsider that however.
- A workaround for Fishwife 1.5.0 is to to use the
none
environment, i.e.fishwife -E none
which will not include the Rack::Chunked middleware.
I'm investigating possible fixes.
And BTW: You can create fishwife pull requests, see the closed examples.
from fishwife.
Thanks, that explains. I'll give the work around a try tomorrow.
Regarding the pull requests, I end up with redirect to my mizuno fork when I try to fork your project. I could delete my mizuno fork but that would leave the open pull requests I have there in limbo. I was about to split of my fork of that when I found your project :-)
from fishwife.
OK please give fishwife 1.5.1 a try, where I believe I have stamped out all potential for Rack::Chunked to do harm.
Re: pull requests: FYI: You can add my fishwife repo as an additional remote to your existing repo, and submit pull request topic branches off of the the fishwife branch, ie:
git remote add fishwife git://github.com/dekellum/fishwife.git
git fetch fishwife
git checkout -t -b fishwife fishwife/fishwife
git checkout -b for-fishwife-topic
from fishwife.
Works great now. Thanks for looking into this.
from fishwife.
Related Issues (9)
- Rack 2.x support HOT 3
- Configuration of jetty? HOT 1
- Is async supported? HOT 6
- Silently fallback to WEBrick or panic: failed to coerce org.slf4j.helpers.NOPLoggerFactory to ch.qos.logback.core.Context HOT 10
- java.lang.NoSuchMethodError on Jruby 9.3.3.0 nightly build HOT 3
- rack.input does not rewind HOT 7
- logging configuration, defaults & documentation HOT 3
- :async in fishwife HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fishwife.