@@ -52,7 +52,14 @@ withServerRunning root f
52
52
info " Finished with server" )
53
53
54
54
serverRunningArgs :: [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
+ ]
56
63
57
64
waitForServer :: IO ()
58
65
waitForServer = f 10
@@ -261,9 +268,15 @@ testPort = 8392
261
268
mkUrl :: RelativeURL -> AbsoluteURL
262
269
mkUrl relPath = " http://127.0.0.1:" ++ show testPort ++ relPath
263
270
271
+ mkUserContentUrl :: RelativeURL -> AbsoluteURL
272
+ mkUserContentUrl relPath = " http://localhost:" ++ show testPort ++ relPath
273
+
264
274
mkGetReq :: RelativeURL -> Request_String
265
275
mkGetReq url = getRequest (mkUrl url)
266
276
277
+ mkGetUserContentReq :: RelativeURL -> Request_String
278
+ mkGetUserContentReq url = getRequest (mkUserContentUrl url)
279
+
267
280
mkPostReq :: RelativeURL -> [(String , String )] -> Request_String
268
281
mkPostReq url vals =
269
282
setRequestBody (postRequest (mkUrl url))
@@ -295,15 +308,27 @@ putRequest urlString =
295
308
getUrl :: Authorization -> RelativeURL -> IO String
296
309
getUrl auth url = Http. execRequest auth (mkGetReq url)
297
310
311
+ getUserContentUrl :: Authorization -> RelativeURL -> IO String
312
+ getUserContentUrl auth url = Http. execRequest auth (mkGetUserContentReq url)
313
+
298
314
getETag :: RelativeURL -> IO String
299
315
getETag url = Http. responseHeader HdrETag (mkGetReq url)
300
316
317
+ getETagUserContent :: RelativeURL -> IO String
318
+ getETagUserContent url = Http. responseHeader HdrETag (mkGetUserContentReq url)
319
+
301
320
mkGetReqWithETag :: String -> RelativeURL -> Request_String
302
321
mkGetReqWithETag url etag =
303
322
Request (fromJust $ parseURI $ mkUrl url) GET hdrs " "
304
323
where
305
324
hdrs = [mkHeader HdrIfNoneMatch etag]
306
325
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
+
307
332
validateETagHandling :: RelativeURL -> IO ()
308
333
validateETagHandling url = void $ do
309
334
etag <- getETag url
@@ -313,6 +338,15 @@ validateETagHandling url = void $ do
313
338
checkETag etag = void $ Http. execRequest' NoAuth (mkGetReqWithETag url etag) isNotModified
314
339
checkETagMismatch etag = void $ Http. execRequest NoAuth (mkGetReqWithETag url etag)
315
340
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
+
316
350
getJSONStrings :: RelativeURL -> IO [String ]
317
351
getJSONStrings url = getUrl NoAuth url >>= decodeJSON
318
352
0 commit comments