-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ Start server: | |
|
||
```shell | ||
cd nodejs | ||
node main.js | ||
node download.js | ||
``` | ||
|
||
Start benchmark: | ||
|
This file contains 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 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
File renamed without changes.
This file contains 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,38 @@ | ||
const https = require('https'); | ||
const fs = require('fs'); | ||
|
||
const PORT = 3000; | ||
const HOST = '0.0.0.0'; | ||
|
||
// Read SSL certificate and private key | ||
const privateKey = fs.readFileSync('../cert/privateKey.pem', 'utf8'); | ||
const certificate = fs.readFileSync('../cert/cert.pem', 'utf8'); | ||
const credentials = { key: privateKey, cert: certificate }; | ||
|
||
const requestHandler = (request, response) => { | ||
let receivedBytes = 0; | ||
|
||
request.on('data', (chunk) => { | ||
receivedBytes += chunk.length; | ||
// Discard the data | ||
}); | ||
|
||
request.on('end', () => { | ||
console.log(`Received ${receivedBytes} bytes`); | ||
response.statusCode = 200; | ||
response.end('Upload complete'); | ||
}); | ||
|
||
request.on('error', (err) => { | ||
console.error('Error receiving data:', err); | ||
response.statusCode = 500; | ||
response.end('Error receiving data'); | ||
}); | ||
}; | ||
|
||
// Create HTTPS server with the provided SSL credentials and request handler | ||
const server = https.createServer(credentials, requestHandler); | ||
|
||
server.listen(PORT, HOST, () => { | ||
console.log(`Server listening on https://${HOST}:${PORT}`); | ||
}); |
This file contains 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