Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
The caseless npm package is a utility for managing HTTP headers in a case-insensitive manner. It allows you to get, set, and delete headers on an object without worrying about the case sensitivity of the header names.
Setting headers
This feature allows you to set headers on an object. The headers are managed in a case-insensitive way, so setting 'A-Header' would overwrite 'a-header' if it already exists.
{"var caseless = require('caseless');\nvar headers = {};\nvar c = caseless(headers);\nc.set('a-Header', 'the value');\nconsole.log(headers); // Output will be { 'a-header': 'the value' }"}
Getting headers
This feature allows you to retrieve the value of headers regardless of the case of the header name you provide.
{"var caseless = require('caseless');\nvar headers = {'a-header': 'the value'};\nvar c = caseless(headers);\nconsole.log(c.get('A-Header')); // Output will be 'the value'"}
Checking if a header exists
This feature allows you to check if a header exists in the object, regardless of the case of the header name.
{"var caseless = require('caseless');\nvar headers = {'content-type': 'application/json'};\nvar c = caseless(headers);\nconsole.log(c.has('Content-Type')); // Output will be true"}
Deleting headers
This feature allows you to delete headers from the object. The deletion is case-insensitive.
{"var caseless = require('caseless');\nvar headers = {'content-type': 'application/json'};\nvar c = caseless(headers);\nc.delete('Content-Type');\nconsole.log(headers); // Output will be {}"}
This package provides functionality to normalize HTTP header names to a consistent case format. Unlike caseless, which allows for case-insensitive manipulation, header-case-normalizer focuses on converting header names to a specific case format.
This package is similar to caseless in that it allows for case-insensitive handling of HTTP headers. It provides a more extensive API for parsing and formatting HTTP headers, which might be more suitable for complex header manipulation tasks.
This library is incredibly useful when working with HTTP headers. It allows you to get/set/check for headers in a caseless manor while also preserving the caseing of headers the first time they are set.
var headers = {}
, c = caseless(headers)
;
c.set('a-Header', 'asdf')
c.get('a-header') === 'asdf'
Has takes a name and if it finds a matching header will return that header name with the preserved caseing it was set with.
c.has('a-header') === 'a-Header'
Set is fairly straight forward except that if the header exists and clobber is disabled it will add ','+value
to the existing header.
c.set('a-Header', 'fdas')
c.set('a-HEADER', 'more', false)
c.get('a-header') === 'fdsa,more'
Swaps the casing of a header with the new one that is passed in.
var headers = {}
, c = caseless(headers)
;
c.set('a-Header', 'fdas')
c.swap('a-HEADER')
c.has('a-header') === 'a-HEADER'
headers === {'a-HEADER': 'fdas'}
FAQs
Caseless object set/get/has, very useful when working with HTTP headers.
The npm package caseless receives a total of 13,704,665 weekly downloads. As such, caseless popularity was classified as popular.
We found that caseless demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.