summaryrefslogtreecommitdiff
path: root/mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs
diff options
context:
space:
mode:
authorJo Shields <directhex@apebox.org>2014-02-19 22:12:43 +0000
committerJo Shields <directhex@apebox.org>2014-02-19 22:12:43 +0000
commit9972bf87b4f27d9c8f358ef8414ac1ab957a2f0f (patch)
tree5bb230c1d698659115f918e243c1d4b0aa4c7f51 /mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs
parentd0a215f5626219ff7927f576588a777e5331c7be (diff)
downloadmono-upstream/3.2.8+dfsg.tar.gz
Imported Upstream version 3.2.8+dfsgupstream/3.2.8+dfsg
Diffstat (limited to 'mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs')
-rw-r--r--mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs26
1 files changed, 23 insertions, 3 deletions
diff --git a/mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs b/mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs
index 33f87db8f0..7bb2496a94 100644
--- a/mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs
+++ b/mcs/class/System.Net.Http/System.Net.Http.Headers/AuthenticationHeaderValue.cs
@@ -26,6 +26,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Collections.Generic;
+
namespace System.Net.Http.Headers
{
public class AuthenticationHeaderValue : ICloneable
@@ -85,8 +87,23 @@ namespace System.Net.Http.Headers
public static bool TryParse (string input, out AuthenticationHeaderValue parsedValue)
{
var lexer = new Lexer (input);
- var t = lexer.Scan ();
- if (t != Token.Type.Token || !(lexer.PeekChar () == ' ' || lexer.PeekChar () == -1)) {
+ Token token;
+ if (TryParseElement (lexer, out parsedValue, out token) && token == Token.Type.End)
+ return true;
+
+ parsedValue = null;
+ return false;
+ }
+
+ internal static bool TryParse (string input, int minimalCount, out List<AuthenticationHeaderValue> result)
+ {
+ return CollectionParser.TryParse (input, minimalCount, TryParseElement, out result);
+ }
+
+ static bool TryParseElement (Lexer lexer, out AuthenticationHeaderValue parsedValue, out Token t)
+ {
+ t = lexer.Scan ();
+ if (t != Token.Type.Token) {
parsedValue = null;
return false;
}
@@ -95,8 +112,11 @@ namespace System.Net.Http.Headers
parsedValue.Scheme = lexer.GetStringValue (t);
t = lexer.Scan ();
- if (t != Token.Type.End)
+ if (t == Token.Type.Token) {
+ // TODO: Wrong with multi value parsing
parsedValue.Parameter = lexer.GetRemainingStringValue (t.StartPosition);
+ t = new Token (Token.Type.End, 0, 0);
+ }
return true;
}