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

Invariant documented for rqPathInfo doesn't always hold #285

Open
hvr opened this issue May 12, 2019 · 2 comments
Open

Invariant documented for rqPathInfo doesn't always hold #285

hvr opened this issue May 12, 2019 · 2 comments

Comments

@hvr
Copy link
Member

hvr commented May 12, 2019

Not sure if this is a documentation bug or an issue in addRoutes

The documentation specifies the invariant

-- The following identity holds:
--
-- > rqURI r == S.concat [ rqContextPath r
-- > , rqPathInfo r
-- > , let q = rqQueryString r
-- > in if S.null q
-- > then ""
-- > else S.append "?" q
-- > ]

However, I have noticed when mounting a path via

addRoutes [("/foo/",   fooHandler]

that when dumping the request paths via

    liftIO (print rq)
    liftIO (print $ ((rqContextPath rq, rqPathInfo rq, rqQueryString rq), rqURI rq))

You can see that the invariant breaks for the GET /foo HTTP/1.1 corner case:

GET /foo HTTP/1.1
accept: */*
user-agent: curl/7.58.0
host: localhost:8080

sn="localhost:8080" c=127.0.0.1:52732 s=127.0.0.1:8080 ctx=/foo/ clen=n/a
(("/foo/","",""),"/foo")
GET /foo/ HTTP/1.1
accept: */*
user-agent: curl/7.58.0
host: localhost:8080

sn="localhost:8080" c=127.0.0.1:52734 s=127.0.0.1:8080 ctx=/foo/ clen=n/a
(("/foo/","",""),"/foo/")
GET /foo// HTTP/1.1
accept: */*
user-agent: curl/7.58.0
host: localhost:8080

sn="localhost:8080" c=127.0.0.1:52736 s=127.0.0.1:8080 ctx=/foo/ clen=n/a
(("/foo/","/",""),"/foo//")
GET /foo/// HTTP/1.1
accept: */*
user-agent: curl/7.58.0
host: localhost:8080

sn="localhost:8080" c=127.0.0.1:52738 s=127.0.0.1:8080 ctx=/foo/ clen=n/a
(("/foo/","//",""),"/foo///")
@hvr
Copy link
Member Author

hvr commented May 12, 2019

Another corner-case where it doesn't hold:

GET /foo? HTTP/1.1
accept: */*
user-agent: curl/7.58.0
host: localhost:8080

sn="localhost:8080" c=127.0.0.1:52834 s=127.0.0.1:8080 ctx=/foo/ clen=n/a
(("/foo/","",""),"/foo?")

@mightybyte
Copy link
Member

Pinging @gregorycollins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants