-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
153 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#if NETSTANDARD || NETFRAMEWORK | ||
#if !NET | ||
using System.ComponentModel; | ||
|
||
// ReSharper disable once CheckNamespace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) .NET Foundation and Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
using System.Net; | ||
using RestSharp.Tests.Integrated.Server; | ||
|
||
namespace RestSharp.Tests.Integrated; | ||
|
||
[Collection(nameof(TestServerCollection))] | ||
public class RedirectTests { | ||
readonly RestClient _client; | ||
|
||
public RedirectTests(TestServerFixture fixture, ITestOutputHelper output) { | ||
var options = new RestClientOptions(fixture.Server.Url) { | ||
FollowRedirects = true | ||
}; | ||
_client = new RestClient(options); | ||
} | ||
|
||
[Fact] | ||
public async Task Can_Perform_GET_Async_With_Redirect() { | ||
const string val = "Works!"; | ||
|
||
var request = new RestRequest("redirect"); | ||
|
||
var response = await _client.ExecuteAsync<Response>(request); | ||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
response.Data!.Message.Should().Be(val); | ||
} | ||
|
||
class Response { | ||
public string? Message { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace RestSharp.Tests; | ||
|
||
public class OptionsTests { | ||
[Fact] | ||
public void Ensure_follow_redirect() { | ||
var value = false; | ||
var options = new RestClientOptions { FollowRedirects = true, ConfigureMessageHandler = Configure}; | ||
var _ = new RestClient(options); | ||
value.Should().BeTrue(); | ||
|
||
HttpMessageHandler Configure(HttpMessageHandler handler) { | ||
value = ((handler as HttpClientHandler)!).AllowAutoRedirect; | ||
return handler; | ||
} | ||
} | ||
} |