diff options
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index d731ac5..1feeeb3 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Collections.Specialized; | 31 | using System.Collections.Specialized; |
32 | using System.Globalization; | ||
32 | using System.IO; | 33 | using System.IO; |
33 | using System.Net; | 34 | using System.Net; |
34 | using System.Net.Security; | 35 | using System.Net.Security; |
@@ -557,34 +558,27 @@ namespace OpenSim.Framework | |||
557 | { | 558 | { |
558 | float qx = GetQ(x); | 559 | float qx = GetQ(x); |
559 | float qy = GetQ(y); | 560 | float qy = GetQ(y); |
560 | if (qx < qy) | 561 | return qy.CompareTo(qx); // descending order |
561 | return -1; | ||
562 | if (qx == qy) | ||
563 | return 0; | ||
564 | return 1; | ||
565 | } | 562 | } |
566 | 563 | ||
567 | private float GetQ(Object o) | 564 | private float GetQ(Object o) |
568 | { | 565 | { |
569 | // Example: image/png;q=0.9 | 566 | // Example: image/png;q=0.9 |
570 | 567 | ||
568 | float qvalue = 1F; | ||
571 | if (o is String) | 569 | if (o is String) |
572 | { | 570 | { |
573 | string mime = (string)o; | 571 | string mime = (string)o; |
574 | string[] parts = mime.Split(new char[] { ';' }); | 572 | string[] parts = mime.Split(';'); |
575 | if (parts.Length > 1) | 573 | if (parts.Length > 1) |
576 | { | 574 | { |
577 | string[] kvp = parts[1].Split(new char[] { '=' }); | 575 | string[] kvp = parts[1].Split('='); |
578 | if (kvp.Length == 2 && kvp[0] == "q") | 576 | if (kvp.Length == 2 && kvp[0] == "q") |
579 | { | 577 | float.TryParse(kvp[1], NumberStyles.Number, CultureInfo.InvariantCulture, out qvalue); |
580 | float qvalue = 1F; | ||
581 | float.TryParse(kvp[1], out qvalue); | ||
582 | return qvalue; | ||
583 | } | ||
584 | } | 578 | } |
585 | } | 579 | } |
586 | 580 | ||
587 | return 1F; | 581 | return qvalue; |
588 | } | 582 | } |
589 | } | 583 | } |
590 | 584 | ||