Patch from Jesper Krogh to keep Engine::HTTP from crashing when used with IE
Andy Grundman [Mon, 23 Oct 2006 02:16:39 +0000 (02:16 +0000)]
Changes
lib/Catalyst/Engine/HTTP.pm

diff --git a/Changes b/Changes
index f5cbf01..239af68 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 This file documents the revision history for Perl extension Catalyst.
 
 ?        ?
+       - Fix Engine::HTTP crash when using IE. (Jesper Krogh)
        - clean up Catalyst::Utils to handle some edge cases
        - Properly work around lighttpd PATH_INFO vs. SCRIPT_NAME bug.
          (Mark Blythe)
index fa653d9..881bf27 100644 (file)
@@ -335,16 +335,23 @@ sub _parse_request_line {
 sub _socket_data {
     my ( $self, $handle ) = @_;
 
-    my $remote_sockaddr = getpeername($handle);
-    my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr);
-    my $local_sockaddr = getsockname($handle);
+    my $iaddr;
+    
+    my $remote_sockaddr       = getpeername($handle);
+    ( undef, $iaddr )         = sockaddr_in($remote_sockaddr);
+    my $local_sockaddr        = getsockname($handle);
     my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr);
 
+    # This mess is necessary to keep IE from crashing the server
     my $data = {
-        peername => gethostbyaddr( $iaddr, AF_INET ) || "localhost",
-        peeraddr => inet_ntoa($iaddr) || "127.0.0.1",
-        localname => gethostbyaddr( $localiaddr, AF_INET ) || "localhost",
-        localaddr => inet_ntoa($localiaddr) || "127.0.0.1",
+        peername  => $iaddr 
+            ? ( gethostbyaddr( $iaddr, AF_INET ) || 'localhost' )
+            : 'localhost',
+        peeraddr  => $iaddr 
+            ? ( inet_ntoa($iaddr) || '127.0.0.1' )
+            : '127.0.0.1',
+        localname => gethostbyaddr( $localiaddr, AF_INET ) || 'localhost',
+        localaddr => inet_ntoa($localiaddr) || '127.0.0.1',
     };
 
     return $data;