Serving images using Rack + IIS + Rails?

Hi all,

I’ve got a Windows 2008 / IIS 7 server, and a default Rails app working
with:

Rails 2.3.5
Rack gem (1.0.1)
IronRuby 1.0 RTM
IronRuby.Rack.dll built from Git HEAD.

It seems like images are being corrupted? Static content like
/javascripts/prototype.js looks fine, but I get a broken image when
requesting /images/rails.png

Running curl, the headers looked OK:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 6646
Content-Type: image/png; charset=utf-8
Last-Modified: Thu, 20 May 2010 18:50:34 GMT
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 21 May 2010 18:11:54 GMT

(However, it displays correctly when using the local “ir script\server”
(just webrick) http://localhost:3000/images/rails.png)

(It looks like Bobby J. has the same or similar issue in his
screencast
@
http://www.iamnotmyself.com/2010/04/22/RunningRailsInIIS7WithIronRubyRack.aspx(15m
04s))

Any ideas?

Thanks,
Ed C.

Hi Eddie,

This is a known issue with the ironrack implementation. I had thought it
was
going to be fixed with the next push to github, but it looks like it was
not. try searching the mailing list for jimmy’s comments on it. couple
workarounds for you… 1. fix it… 8) 2. set up a images subdomain for
hosting image files that does not go though rack. so all your images
would
come from images.mysite.com.

On Fri, May 21, 2010 at 11:13 AM, Eddie Cianci
[email protected]wrote:

It seems like images are being corrupted? Static content like
Server: Microsoft-IIS/7.0


“The explanation requiring the fewest assumptions is most likely to be
correct.”

Hi Bobby,

I hadn’t seen anything on the Codeplex site, but I did just find this
post
from Jimmy @ Attempting To Get IronRuby.Rack Running a non-demo rails site - IronRuby - Ruby-Forum

(Apologies for beating a dead horse.)

We’ll be using static asset hosts in production, so using them in
development for the short term works too. Thanks!

Yep, this is a known bug in the current sources; we used response.Write
instead of response.WriteBinary. If you change
Hosts/IronRuby.Rack/Response.cs to use that, images and other binary
files will work again.

Also, it’s another bug that the adapter is serving static files through
Rack, it should just find them itself. This bug and the image bug will
be checked in this weekend.

Let me know if you have any issues.

~Jimmy

On May 21, 2010, at 2:33 PM, “Eddie Cianci”
<[email protected]mailto:[email protected]> wrote:

Hi all,

I’ve got a Windows 2008 / IIS 7 server, and a default Rails app working
with:

Rails 2.3.5
Rack gem (1.0.1)
IronRuby 1.0 RTM
IronRuby.Rack.dll built from Git HEAD.

It seems like images are being corrupted? Static content like
/javascripts/prototype.js looks fine, but I get a broken image when
requesting /images/rails.png

Running curl, the headers looked OK:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 6646
Content-Type: image/png; charset=utf-8
Last-Modified: Thu, 20 May 2010 18:50:34 GMT
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: http://ASP.NET ASP.NEThttp://ASP.NET
Date: Fri, 21 May 2010 18:11:54 GMT

(However, it displays correctly when using the local “ir script\server”
(just webrick) http://localhost:3000/images/rails.png
http://localhost:3000/images/rails.png)

(It looks like Bobby J. has the same or similar issue in his
screencast @
http://www.iamnotmyself.com/2010/04/22/RunningRailsInIIS7WithIronRubyRack.aspx
http://www.iamnotmyself.com/2010/04/22/RunningRailsInIIS7WithIronRubyRack.aspx
(15m 04s))

Any ideas?

Thanks,
Ed C.


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core