Skip to content

Commit

Permalink
more redirection/cookie related routes
Browse files Browse the repository at this point in the history
  • Loading branch information
rassilon committed Aug 29, 2023
1 parent a459530 commit df851af
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/RestSharp.Tests.Integrated/Server/TestServer.cs
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Logging;
using RestSharp.Tests.Integrated.Server.Handlers;
using RestSharp.Tests.Shared.Extensions;
using System.Net;

// ReSharper disable ConvertClosureToMethodGroup

Expand Down Expand Up @@ -41,6 +42,11 @@ public sealed class HttpServer {

// Cookies
_app.MapGet("get-cookies", CookieHandlers.HandleCookies);
_app.MapPut("get-cookies",
(HttpContext cxt) => {
// Make sure we get the status code we expect:
return Results.StatusCode(405);
});
_app.MapGet("set-cookies", CookieHandlers.HandleSetCookies);
_app.MapGet("redirect", () => Results.Redirect("/success", false, true));

Expand All @@ -58,6 +64,18 @@ public sealed class HttpServer {
ctx.Response.Cookies.Append("redirectCookie", "value1");
return Results.Redirect("/get-cookies", permanent: false, preserveMethod: false);
});
_app.MapPost(
"/post/set-cookie-seeother",
(HttpContext ctx) => {
ctx.Response.Cookies.Append("redirectCookie", "seeOtherValue1");
return new RedirectWithStatusCodeResult((int)HttpStatusCode.SeeOther, "/get-cookies");
});
_app.MapPut(
"/put/set-cookie-redirect",
(HttpContext ctx) => {
ctx.Response.Cookies.Append("redirectCookie", "putCookieValue1");
return Results.Redirect("/get-cookies", permanent: false, preserveMethod: false);
});

// PUT
_app.MapPut(
Expand Down

0 comments on commit df851af

Please sign in to comment.