-
Notifications
You must be signed in to change notification settings - Fork 3.4k
test-http-client-headers-array #19411
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
388e8e3
WIP: test-http-client-headers-array
pfgithub ced7098
test-http-client-headers-array
pfgithub 8ffac32
test for headers
pfgithub 7de992d
remove file
pfgithub 1378219
move to c++ and add a server test
pfgithub 7418623
no a.js
pfgithub 144a5be
Merge branch 'main' into pfg/node-3
pfgithub e8694cd
Merge branch 'main' into pfg/node-3
pfgithub b73e9d4
Merge branch 'main' into pfg/node-3
pfgithub e97bd43
`bun run prettier`
pfgithub 3123c2b
Merge branch 'main' into pfg/node-3
cirospaciari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const http = require("node:http"); | ||
|
||
const server = http.createServer((req, res) => { | ||
// Set response headers | ||
res.setHeader("Content-Type", "text/plain"); | ||
res.setHeader("X-Powered-By", "Node.js"); | ||
res.setHeader("Cache-Control", ["no-cache", "yes-cache"]); | ||
res.appendHeader("Cache-Control", "maybe-cache"); | ||
res.appendHeader("Cache-Control", ["please-cache", "please-dont-cache"]); | ||
res.setHeader("Set-Cookie", ["a=b", "c=d"]); | ||
res.appendHeader("Set-Cookie", "e=f"); | ||
res.appendHeader("Set-Cookie", ["g=h", "i=j"]); | ||
res.setHeader("Abc", ["list-one", "list-two"]); | ||
res.setHeader("Abc", ["list-three", "list-four"]); | ||
|
||
// Write response | ||
res.statusCode = 200; | ||
res.end("Hello World\n"); | ||
}); | ||
|
||
const PORT = 0; | ||
server.listen(PORT, async () => { | ||
const port = server.address().port; | ||
console.log(`Server running`); | ||
|
||
// Test the server response headers using fetch | ||
try { | ||
const response = await fetch(`http://localhost:${port}/`); | ||
console.log("Response status: " + response.status); | ||
|
||
// Check headers | ||
console.log("Headers test results:"); | ||
response.headers.delete("date"); | ||
for (const [key, value] of response.headers.entries()) { | ||
console.log(`${key}: ${value}`); | ||
} | ||
|
||
const body = await response.text(); | ||
console.log("Body:", body); | ||
process.exit(0); | ||
} catch (error) { | ||
console.error("Error testing server:", error); | ||
process.exit(1); | ||
} finally { | ||
// Uncomment to close server after test | ||
// server.close(); | ||
} | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.