In my environment, this is pretty much a non-issue because we can,
like you said, handle that in Apache, but I figured I'd post a patch
anyways. Of course, I should have tested it fully first. This should
work better.
Index: lib/switchpipe.rb
===================================================================
--- lib/switchpipe.rb (revision 44)
+++ lib/switchpipe.rb (working copy)
@@ -461,7 +461,7 @@
when :tcp
TCPSocket.new(instance[:host], instance[:port])
end rescue nil
-
+
# If the backend isn't responding, let's just panic and get
outta here..
unless sock
send_data "HTTP/1.1 500 Internal Server Error\r
\nConnection: close\r\nContent-Length: 27\r\nContent-Type: text/plain\r
\n\r\nBackend application failure"
@@ -478,6 +478,7 @@
@request.headers['connection'] = ['Connection', 'close']
# Write out the HTTP request, with some minor changes
(removal of the app identifier path, for one)
+
if found_by == :path
sock.write @request.request_line_without_app + "\r\n" +
@request.header_string + "\r\n\r\n"
else
@@ -571,12 +572,12 @@
# Returns the first directory name in the path requested. This is
the "application name" in SwitchPipe-land.
def app_from_path
- path.include?('/') and path.split('/').first
+ app = path.include?('/') ? path.split('/').first : path
end
# Returns the actual location part of the path, as understood by
SwitchPipe at least.
def path_remainder
- "/#{path.match(/[^\/]+\/(.*)/)[1]}" rescue nil
+ "/#{path.match(/[^\/]+\/(.*)/)[1]}" rescue '/'
end
# Returns the HTTP verb used (GET, POST, PUT, etc)
On Apr 10, 4:17 am, Peter Cooper <
pcoo...@gmail.com> wrote:
> On Apr 9, 7:58 pm, Mike Auclair <
maucl...@nicusa.com> wrote:
>
> > Switchpipe doesn't seem to know what to do if it receives a request
> > with no trailing slash, iehttp://host/appinsteadofhttp://host/app/.