Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpContext.ValidatePreconditions returns NoConditionsSpecified instead of AllConditionsMet when conditions pass #402

Closed
cmeeren opened this issue Feb 15, 2020 · 1 comment
Labels
bug Reproducible bug PR approved A PR for this issue will get accepted (as long as inline with the comms)

Comments

@cmeeren
Copy link

cmeeren commented Feb 15, 2020

I think it might happen with ETag and If-Match, too.

Console app repro:

namespace Repro

open System
open Microsoft.AspNetCore.Http
open Giraffe

module Program =
  [<EntryPoint>]
  let main args =
    let ctx = DefaultHttpContext()
    ctx.Request.GetTypedHeaders().IfUnmodifiedSince <- Nullable(DateTimeOffset.Parse "Sat, 01 Jan 2000 00:00:00 GMT")
    Console.WriteLine("Should return ConditionFailed:")
    let result = ctx.ValidatePreconditions None (Some (DateTimeOffset.Parse "Sun, 02 Jan 2000 00:00:00 GMT"))
    Console.WriteLine(result)

    let ctx = DefaultHttpContext()
    ctx.Request.GetTypedHeaders().IfUnmodifiedSince <- Nullable(DateTimeOffset.Parse "Sat, 01 Jan 2000 00:00:00 GMT")
    Console.WriteLine("Should return AllConditionsMet:")
    let result = ctx.ValidatePreconditions None (Some (DateTimeOffset.Parse "Sat, 01 Jan 2000 00:00:00 GMT"))
    Console.WriteLine(result)

    0

Output:

Should return ConditionFailed:
ConditionFailed
Should return AllConditionsMet:
NoConditionsSpecified
@dustinmoris
Copy link
Member

Thanks for raising this bug, I'll look into it!

@dustinmoris dustinmoris added bug Reproducible bug PR approved A PR for this issue will get accepted (as long as inline with the comms) labels Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible bug PR approved A PR for this issue will get accepted (as long as inline with the comms)
Projects
None yet
Development

No branches or pull requests

2 participants