From 4234c64147cd59c284276a5408702c31860a5928 Mon Sep 17 00:00:00 2001
From: dahlia
Date: Wed, 2 Dec 2009 04:10:53 -0800
Subject: handle a condition where the http headers apparently have multiple
 remote ports designated

---
 OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
index c53160f..bcfb0a4 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
@@ -188,7 +188,15 @@ namespace OpenSim.Framework.Servers.HttpServer
                 try
                 {
                     IPAddress addr = IPAddress.Parse(req.Headers["remote_addr"]);
-                    int port = Int32.Parse(req.Headers["remote_port"]);
+                    // sometimes req.Headers["remote_port"] returns a comma separated list, so use
+                    // the first one in the list and log it 
+                    string[] strPorts = req.Headers["remote_port"].Split(new char[] { ',' });
+                    if (strPorts.Length > 1)
+                    {
+                        _log.ErrorFormat("[OSHttpRequest]: format exception on addr/port {0}:{1}, ignoring",
+                                     req.Headers["remote_addr"], req.Headers["remote_port"]);
+                    }
+                    int port = Int32.Parse(strPorts[0]);
                     _remoteIPEndPoint = new IPEndPoint(addr, port);
                 }
                 catch (FormatException)
-- 
cgit v1.1