Skip to content

Commit

Permalink
fetch: wpt add /fetch/api/resources/cache.py to server.mjs (#3225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed May 8, 2024
1 parent 1be2c9c commit 60efbf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions test/wpt/server/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ const server = createServer(async (req, res) => {
res.end()
break
}
case '/fetch/api/resources/cache.py': {
if (req.headers['if-none-match'] === '"123abc"') {
res.statusCode = 304
res.statusMessage = 'Not Modified'
res.setHeader('X-HTTP-STATUS', '304')
res.end()
} else {
// cache miss, so respond with the actual content
res.statusCode = 200
res.statusMessage = 'OK'
res.setHeader('Content-Type', 'text/plain')
res.setHeader('ETag', '"123abc"')
res.end('lorem ipsum dolor sit amet')
}
break
}
case '/fetch/api/resources/status.py': {
const code = parseInt(fullUrl.searchParams.get('code') ?? 200)
const text = fullUrl.searchParams.get('text') ?? 'OMG'
Expand Down
3 changes: 2 additions & 1 deletion test/wpt/status/fetch.status.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"conditional-get.any.js": {
"fail": [
"Testing conditional GET with ETags"
]
],
"note": "undici doesn't keep track of etags"
},
"header-value-combining.any.js": {
"fail": [
Expand Down

0 comments on commit 60efbf0

Please sign in to comment.