Commit 1207f21a authored by titanium007's avatar titanium007

issue #2 fix

Add Basic Authentication header if it does not exists in response
header. This is needed for prompting the user when all other
authentication method fails (like NTLM & Negotiate)
parent cd77ea43
...@@ -41,6 +41,7 @@ namespace Titanium.HTTPProxyServer ...@@ -41,6 +41,7 @@ namespace Titanium.HTTPProxyServer
header = s; header = s;
value = response.Headers[s]; value = response.Headers[s];
} }
else else
returnHeaders.Add(new Tuple<String, String>(s, response.Headers[s])); returnHeaders.Add(new Tuple<String, String>(s, response.Headers[s]));
} }
...@@ -53,7 +54,11 @@ namespace Titanium.HTTPProxyServer ...@@ -53,7 +54,11 @@ namespace Titanium.HTTPProxyServer
returnHeaders.Add(new Tuple<String, String>("Set-Cookie", cookie)); returnHeaders.Add(new Tuple<String, String>("Set-Cookie", cookie));
} }
if (returnHeaders.Any(x => x.Item1.ToLower().Equals("www-authenticate")))
{
if (returnHeaders.Any(x => x.Item1.ToLower().Equals("www-authenticate") == false && x.Item2.ToLower().Equals("basic") == false))
returnHeaders.Add(new Tuple<String, String>("WWW-Authenticate", "Basic"));
}
return returnHeaders; return returnHeaders;
} }
...@@ -131,13 +136,13 @@ namespace Titanium.HTTPProxyServer ...@@ -131,13 +136,13 @@ namespace Titanium.HTTPProxyServer
{ {
for(int i=1; i<requestLines.Count; i++) for (int i = 1; i < requestLines.Count; i++)
{ {
String httpCmd = requestLines[i]; String httpCmd = requestLines[i];
String[] header = httpCmd.Split(colonSpaceSplit, 2, StringSplitOptions.None); String[] header = httpCmd.Split(colonSpaceSplit, 2, StringSplitOptions.None);
if(!String.IsNullOrEmpty(header[0].Trim())) if (!String.IsNullOrEmpty(header[0].Trim()))
switch (header[0].ToLower()) switch (header[0].ToLower())
{ {
case "accept": case "accept":
...@@ -204,7 +209,7 @@ namespace Titanium.HTTPProxyServer ...@@ -204,7 +209,7 @@ namespace Titanium.HTTPProxyServer
break; break;
default: default:
if(header.Length>0) if (header.Length > 0)
webReq.Headers.Add(header[0], header[1]); webReq.Headers.Add(header[0], header[1]);
else else
webReq.Headers.Add(header[0], ""); webReq.Headers.Add(header[0], "");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment