return null;
string header = challenge.Trim ();
- if (header.ToLower ().IndexOf ("basic") == -1)
+ if (header.ToLower ().IndexOf ("basic", StringComparison.Ordinal) == -1)
return null;
return InternalAuthenticate (webRequest, credentials);
if (lp.Path.IndexOf ('%') != -1)
throw new HttpListenerException (400, "Invalid path.");
- if (lp.Path.IndexOf ("//") != -1) // TODO: Code?
+ if (lp.Path.IndexOf ("//", StringComparison.Ordinal) != -1) // TODO: Code?
throw new HttpListenerException (400, "Invalid path.");
// Always listens on all the interfaces, no matter the host name/ip used.
if (lp.Path.IndexOf ('%') != -1)
return;
- if (lp.Path.IndexOf ("//") != -1)
+ if (lp.Path.IndexOf ("//", StringComparison.Ordinal) != -1)
return;
EndPointListener epl = GetEPListener (IPAddress.Any, lp.Port, listener, lp.Secure);
if (str.Length == 0)
continue;
if (str.StartsWith ("$Version")) {
- version = Int32.Parse (Unquote (str.Substring (str.IndexOf ("=") + 1)));
+ version = Int32.Parse (Unquote (str.Substring (str.IndexOf ('=') + 1)));
} else if (str.StartsWith ("$Path")) {
if (current != null)
- current.Path = str.Substring (str.IndexOf ("=") + 1).Trim ();
+ current.Path = str.Substring (str.IndexOf ('=') + 1).Trim ();
} else if (str.StartsWith ("$Domain")) {
if (current != null)
- current.Domain = str.Substring (str.IndexOf ("=") + 1).Trim ();
+ current.Domain = str.Substring (str.IndexOf ('=') + 1).Trim ();
} else if (str.StartsWith ("$Port")) {
if (current != null)
- current.Port = str.Substring (str.IndexOf ("=") + 1).Trim ();
+ current.Port = str.Substring (str.IndexOf ('=') + 1).Trim ();
} else {
if (current != null) {
cookies.Add (current);
}
current = new Cookie ();
- int idx = str.IndexOf ("=");
+ int idx = str.IndexOf ('=');
if (idx > 0) {
current.Name = str.Substring (0, idx).Trim ();
current.Value = str.Substring (idx + 1).Trim ();
encoding = Encoding.Default;
if (content_type != null) {
- if (content_encoding != null && content_type.IndexOf ("charset=") == -1) {
+ if (content_encoding != null && content_type.IndexOf ("charset=", StringComparison.Ordinal) == -1) {
string enc_name = content_encoding.WebName;
headers.SetInternal ("Content-Type", content_type + "; charset=" + enc_name);
} else {
if (val == "keep-alive" || val == "close")
throw new ArgumentException ("Keep-Alive and Close may not be set with this property");
- if (keepAlive && val.IndexOf ("keep-alive") == -1)
+ if (keepAlive && val.IndexOf ("keep-alive", StringComparison.Ordinal) == -1)
value = value + ", Keep-Alive";
webHeaders.RemoveAndAdd ("Connection", value);
if (contentType == null)
return "ISO-8859-1";
string val = contentType.ToLower ();
- int pos = val.IndexOf ("charset=");
+ int pos = val.IndexOf ("charset=", StringComparison.Ordinal);
if (pos == -1)
return "ISO-8859-1";
pos += 8;
string contentType = ContentType;\r
if (contentType == null)\r
return "ISO-8859-1";\r
- int pos = contentType.IndexOf ("charset=", StringComparison.InvariantCultureIgnoreCase);\r
+ int pos = contentType.IndexOf ("charset=", StringComparison.OrdinalIgnoreCase);\r
if (pos == -1)\r
return "ISO-8859-1";\r
pos += 8;\r
X509Extension ext = cert.Extensions ["2.16.840.1.113730.1.1"];
if (ext != null) {
string text = ext.NetscapeCertType (false);
- return text.IndexOf ("SSL Server Authentication") != -1;
+ return text.IndexOf ("SSL Server Authentication", StringComparison.Ordinal) != -1;
}
return true;
} catch (Exception e) {
WebConnectionStream stream = new WebConnectionStream (cnc);
string contentType = data.Headers ["Transfer-Encoding"];
- cnc.chunkedRead = (contentType != null && contentType.ToLower ().IndexOf ("chunked") != -1);
+ cnc.chunkedRead = (contentType != null && contentType.IndexOf ("chunked", StringComparison.OrdinalIgnoreCase) != -1);
if (!cnc.chunkedRead) {
stream.ReadBuffer = cnc.buffer;
stream.ReadBufferOffset = pos;
bool keepAlive = (Data.Version == HttpVersion.Version11 && this.keepAlive);
if (cncHeader != null) {
cncHeader = cncHeader.ToLower ();
- keepAlive = (this.keepAlive && cncHeader.IndexOf ("keep-alive") != -1);
+ keepAlive = (this.keepAlive && cncHeader.IndexOf ("keep-alive", StringComparison.Ordinal) != -1);
}
if ((socket != null && !socket.Connected) ||
- (!keepAlive || (cncHeader != null && cncHeader.IndexOf ("close") != -1))) {
+ (!keepAlive || (cncHeader != null && cncHeader.IndexOf ("close", StringComparison.Ordinal) != -1))) {
Close (false);
}
write_timeout = read_timeout;
this.cnc = cnc;
string contentType = cnc.Data.Headers ["Transfer-Encoding"];
- bool chunkedRead = (contentType != null && contentType.ToLower ().IndexOf ("chunked") != -1);
+ bool chunkedRead = (contentType != null && contentType.IndexOf ("chunked", StringComparison.OrdinalIgnoreCase) != -1);
string clength = cnc.Data.Headers ["Content-Length"];
if (!chunkedRead && clength != null && clength != "") {
try {
bool isProxy = (request.Proxy != null && !request.Proxy.IsBypassed (request.Address));
string header_name = (isProxy) ? "Proxy-Authenticate" : "WWW-Authenticate";
string authHeader = cnc.Data.Headers [header_name];
- return (authHeader != null && authHeader.IndexOf ("NTLM") != -1);
+ return (authHeader != null && authHeader.IndexOf ("NTLM", StringComparison.Ordinal) != -1);
}
internal void CheckResponseInBuffer ()
if (address == null)
return null;
- if (address.IndexOf ("://") == -1)
+ if (address.IndexOf ("://", StringComparison.Ordinal) == -1)
address = "http://" + address;
return new Uri (address);