@@ -52,7 +52,14 @@ withServerRunning root f
5252 info " Finished with server" )
5353
5454serverRunningArgs :: [String ]
55- serverRunningArgs = [" run" , " --ip" , " 127.0.0.1" , " --port" , show testPort, " --delay-cache-updates" , " 0" ]
55+ serverRunningArgs =
56+ [" run" , " --ip" , " 127.0.0.1"
57+ , " --port" , show testPort
58+ , " --delay-cache-updates" , " 0"
59+ , " --base-uri" , " http://127.0.0.1:" <> show testPort
60+ , " --user-content-uri" , " http://localhost:" <> show testPort
61+ , " --required-base-host-header" , " 127.0.0.1:" <> show testPort
62+ ]
5663
5764waitForServer :: IO ()
5865waitForServer = f 10
@@ -261,9 +268,15 @@ testPort = 8392
261268mkUrl :: RelativeURL -> AbsoluteURL
262269mkUrl relPath = " http://127.0.0.1:" ++ show testPort ++ relPath
263270
271+ mkUserContentUrl :: RelativeURL -> AbsoluteURL
272+ mkUserContentUrl relPath = " http://localhost:" ++ show testPort ++ relPath
273+
264274mkGetReq :: RelativeURL -> Request_String
265275mkGetReq url = getRequest (mkUrl url)
266276
277+ mkGetUserContentReq :: RelativeURL -> Request_String
278+ mkGetUserContentReq url = getRequest (mkUserContentUrl url)
279+
267280mkPostReq :: RelativeURL -> [(String , String )] -> Request_String
268281mkPostReq url vals =
269282 setRequestBody (postRequest (mkUrl url))
@@ -295,15 +308,27 @@ putRequest urlString =
295308getUrl :: Authorization -> RelativeURL -> IO String
296309getUrl auth url = Http. execRequest auth (mkGetReq url)
297310
311+ getUserContentUrl :: Authorization -> RelativeURL -> IO String
312+ getUserContentUrl auth url = Http. execRequest auth (mkGetUserContentReq url)
313+
298314getETag :: RelativeURL -> IO String
299315getETag url = Http. responseHeader HdrETag (mkGetReq url)
300316
317+ getETagUserContent :: RelativeURL -> IO String
318+ getETagUserContent url = Http. responseHeader HdrETag (mkGetUserContentReq url)
319+
301320mkGetReqWithETag :: String -> RelativeURL -> Request_String
302321mkGetReqWithETag url etag =
303322 Request (fromJust $ parseURI $ mkUrl url) GET hdrs " "
304323 where
305324 hdrs = [mkHeader HdrIfNoneMatch etag]
306325
326+ mkGetUserContentReqWithETag :: String -> RelativeURL -> Request_String
327+ mkGetUserContentReqWithETag url etag =
328+ Request (fromJust $ parseURI $ mkUserContentUrl url) GET hdrs " "
329+ where
330+ hdrs = [mkHeader HdrIfNoneMatch etag]
331+
307332validateETagHandling :: RelativeURL -> IO ()
308333validateETagHandling url = void $ do
309334 etag <- getETag url
@@ -313,6 +338,15 @@ validateETagHandling url = void $ do
313338 checkETag etag = void $ Http. execRequest' NoAuth (mkGetReqWithETag url etag) isNotModified
314339 checkETagMismatch etag = void $ Http. execRequest NoAuth (mkGetReqWithETag url etag)
315340
341+ validateETagHandlingUserContent :: RelativeURL -> IO ()
342+ validateETagHandlingUserContent url = void $ do
343+ etag <- getETagUserContent url
344+ checkETag etag
345+ checkETagMismatch (etag ++ " garbled123" )
346+ where
347+ checkETag etag = void $ Http. execRequest' NoAuth (mkGetUserContentReqWithETag url etag) isNotModified
348+ checkETagMismatch etag = void $ Http. execRequest NoAuth (mkGetUserContentReqWithETag url etag)
349+
316350getJSONStrings :: RelativeURL -> IO [String ]
317351getJSONStrings url = getUrl NoAuth url >>= decodeJSON
318352
0 commit comments