[Modify] Use the Uri class

This commit is contained in:
sta 2019-12-24 16:11:47 +09:00
parent f9e37388f8
commit 8064569d41

View File

@ -72,7 +72,7 @@ namespace WebSocketSharp.Net
private WebHeaderCollection _headers; private WebHeaderCollection _headers;
private bool _headersSent; private bool _headersSent;
private bool _keepAlive; private bool _keepAlive;
private string _location; private Uri _location;
private ResponseStream _outputStream; private ResponseStream _outputStream;
private bool _sendChunked; private bool _sendChunked;
private int _statusCode; private int _statusCode;
@ -180,7 +180,7 @@ namespace WebSocketSharp.Net
} }
if (_location != null) if (_location != null)
headers.InternalSet ("Location", _location, true); headers.InternalSet ("Location", _location.AbsoluteUri, true);
if (_cookies != null) { if (_cookies != null) {
foreach (var cookie in _cookies) { foreach (var cookie in _cookies) {
@ -572,7 +572,7 @@ namespace WebSocketSharp.Net
/// </exception> /// </exception>
public string RedirectLocation { public string RedirectLocation {
get { get {
return _location; return _location != null ? _location.OriginalString : null;
} }
set { set {
@ -596,7 +596,7 @@ namespace WebSocketSharp.Net
if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) if (!Uri.TryCreate (value, UriKind.Absolute, out uri))
throw new ArgumentException ("Not an absolute URL.", "value"); throw new ArgumentException ("Not an absolute URL.", "value");
_location = value; _location = uri;
} }
} }
@ -1020,7 +1020,7 @@ namespace WebSocketSharp.Net
if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) if (!Uri.TryCreate (url, UriKind.Absolute, out uri))
throw new ArgumentException ("Not an absolute URL.", "url"); throw new ArgumentException ("Not an absolute URL.", "url");
_location = url; _location = uri;
_statusCode = 302; _statusCode = 302;
_statusDescription = "Found"; _statusDescription = "Found";
} }