[PATCH] exception if User-Agent header missing
Reported by Brian Candler | April 3rd, 2008 @ 11:10 AM
$ telnet localhost 1337 Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
GET /collab HTTP/1.1
HTTP/1.1 500 Internal Server Error
Connection: close
Date: Thu, 03 Apr 2008 15:06:51 GMT
Content-Type: text/html
Server: WEBrick/1.3.1 (Ruby/1.8.6/2008-03-03)
Content-Length: 309
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD><TITLE>Internal Server Error</TITLE></HEAD>
<BODY>
<H1>Internal Server Error</H1>
can't convert nil into String
<HR>
<ADDRESS>
WEBrick/1.3.1 (Ruby/1.8.6/2008-03-03) at
asterisk1:1337
</ADDRESS>
</BODY>
</HTML>
Connection closed by foreign host.
This turns out to be because User-Agent header is missing.
Suggested patch:
--- helpers/micromenus.rb.orig 2008-04-03 14:29:09.000000000 +0100
+++ helpers/micromenus.rb 2008-04-03 16:09:25.000000000 +0100
@@ -439,7 +439,8 @@
def do_GET(request, response)
response.status = 200
- log "Request from: " + request['User-Agent']
+ user_agent = request['User-Agent'] || 'Unknown'
+ log "Request from: #{user_agent}"
route = request.path[1..-1].split '/'
handler = nil
@@ -464,7 +465,7 @@
response.content_type = 'text/javascript'
response.body = File.read file
else
- mg = MicromenuGenerator.new request, handler || resolve_brand(request['User-Agent']), StringIO.new
+ mg = MicromenuGenerator.new request, handler || resolve_brand(user_agent), StringIO.new
response.content_type = mg.content_type
response['Expires'] = 2
Comments and changes to this ticket
-
Jay Phillips April 3rd, 2008 @ 06:22 PM
- State changed from new to open
Hi bcandler,
Thanks a TON for the patch! I always love it when I see people get involved in the software development process. :)
Though there won't be another release of 0.7.x, I will definitely use these patches in the refactored version of Micromenus that will be included in 0.8.x.
Thanks!
Jay Phillips
-
Jay Phillips April 3rd, 2008 @ 06:23 PM
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป