Skip to content

option to ignore response cookies #2292

Open
@SteveW-AMain

Description

@SteveW-AMain

Overview:

It would be useful to have an option to ignore response cookies; this would allow the ability to accept request data in the case where there are cookies present that throw a CookieException.

Use case:

We have a vendor that is planning a migration from old-domain.com to new-domain.com. For the first phase, they are proxying calls from new-domain.com to old-domain.com, and later will serve directly from new-domain.com (is my understanding).

An API call to api.old-domain.com returns two cookies: one for api.old-domain.com, and one for .old-domain.com; everything works as intended.

An API call to api.new-domain.com returns two cookies: one for api.new-domain.com, and one for .old-domain.com - the latter of which throws a CookieException, due to the domain mismatch. So we lose the request response. I have asked them not to send this invalid (and probably useless?) cookie, but they'd rather say it's my problem, not theirs...

Solution?

It seems like it would be fairly straightforward to add a boolean IgnoreResponseCookies, and check for that here:
https://github.com/restsharp/RestSharp/blob/dev/src/RestSharp/RestClient.Async.cs#L147

So you could optionally set that as part of the incoming request, skip adding cookies if it's true, and avoid any potential cookie exceptions.

Alternatives?

Is there a better solution I'm not thinking of? Is there a reason to prefer it be in Options instead of request? Any other concerns?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions