https://github.com/hex7c0/remove_connection
remove Connection header from http(s) response for Nodejs
https://github.com/hex7c0/remove_connection
nodejs
Last synced: 2 months ago
JSON representation
remove Connection header from http(s) response for Nodejs
- Host: GitHub
- URL: https://github.com/hex7c0/remove_connection
- Owner: hex7c0
- License: gpl-3.0
- Created: 2015-08-24T20:55:53.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-04-23T00:05:42.000Z (about 2 years ago)
- Last Synced: 2025-03-01T12:19:34.372Z (over 1 year ago)
- Topics: nodejs
- Language: JavaScript
- Homepage: https://github.com/hex7c0/remove_connection
- Size: 86.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [remove_connection](https://github.com/hex7c0/remove_connection)
[](https://www.npmjs.com/package/remove_connection)
[](https://travis-ci.org/hex7c0/remove_connection)
[](https://ci.appveyor.com/project/hex7c0/remove_connection)
[](https://david-dm.org/hex7c0/remove_connection)
[](https://coveralls.io/r/hex7c0/remove_connection)
Just a simple hack to remove [Connection header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Connection) from HTTP(S) response.
Similar to [remove_date](https://github.com/hex7c0/remove_date/)
## Installation
Install through NPM
```bash
npm install remove_connection
```
or
```bash
git clone git://github.com/hex7c0/remove_connection.git
```
## API
inside nodejs project
```js
var setConnection = require('remove_connection');
require('http').createServer(function(req, res) {
setConnection(res); // remove Connection header from response
res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
```
as middleware
```js
var setConnection = require('remove_connection').setConnectionMiddleware;
var app = require('express')();
app.use(setConnection()).get('/', function(req, res) {
res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
```
### setConnection(res [, setHeader])
#### options
- `res` - **Object** response to client *(default "required")*
- `setHeader`- **Boolean** setHeader block *(default "optional")*
### setConnectionMiddleware([setHeader])
#### options
- `setHeader`- **Boolean** setHeader block *(default "optional")*
## Examples
Take a look at my [examples](examples)
### [License GPLv3](LICENSE)