Skip to content

Commit df851af

Browse files
committed
more redirection/cookie related routes
1 parent a459530 commit df851af

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/RestSharp.Tests.Integrated/Server/TestServer.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.Extensions.Logging;
66
using RestSharp.Tests.Integrated.Server.Handlers;
77
using RestSharp.Tests.Shared.Extensions;
8+
using System.Net;
89

910
// ReSharper disable ConvertClosureToMethodGroup
1011

@@ -41,6 +42,11 @@ public HttpServer(ITestOutputHelper? output = null) {
4142

4243
// Cookies
4344
_app.MapGet("get-cookies", CookieHandlers.HandleCookies);
45+
_app.MapPut("get-cookies",
46+
(HttpContext cxt) => {
47+
// Make sure we get the status code we expect:
48+
return Results.StatusCode(405);
49+
});
4450
_app.MapGet("set-cookies", CookieHandlers.HandleSetCookies);
4551
_app.MapGet("redirect", () => Results.Redirect("/success", false, true));
4652

@@ -58,6 +64,18 @@ public HttpServer(ITestOutputHelper? output = null) {
5864
ctx.Response.Cookies.Append("redirectCookie", "value1");
5965
return Results.Redirect("/get-cookies", permanent: false, preserveMethod: false);
6066
});
67+
_app.MapPost(
68+
"/post/set-cookie-seeother",
69+
(HttpContext ctx) => {
70+
ctx.Response.Cookies.Append("redirectCookie", "seeOtherValue1");
71+
return new RedirectWithStatusCodeResult((int)HttpStatusCode.SeeOther, "/get-cookies");
72+
});
73+
_app.MapPut(
74+
"/put/set-cookie-redirect",
75+
(HttpContext ctx) => {
76+
ctx.Response.Cookies.Append("redirectCookie", "putCookieValue1");
77+
return Results.Redirect("/get-cookies", permanent: false, preserveMethod: false);
78+
});
6179

6280
// PUT
6381
_app.MapPut(

0 commit comments

Comments
 (0)