Skip to content

Invariant documented for rqPathInfo doesn't always hold #285

@hvr

Description

@hvr

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///")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions