
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
A library for deciding content-type based on media ranges in HTTP Accept headers.
A small Python library supporting content-negotiation.
It is used to decide content type based on a list of media ranges in the accept header, as well as deciding content-language based on the accept-language header.
*/*
.*
.For more information on the accept header, see RFC 7231, section-5.3.2. For more information on the accept-language header, see RFC 7231, section-5.3.5
% pip install content-negotiation
from content_negotiation import decide_content_type, NoAgreeableContentTypeError
accept_headers = ["application/json", "text/html", "text/plain, text/*;q=0.8"]
supported_content_types = ["text/turtle", "application/json"]
try:
content_type = decide_content_type(accept_headers, supported_content_types)
except NoAgreeableContentTypeError:
print("No agreeable content type found.")
# Handle error, by returning e.g. 406 Not Acceptable
from content_negotiation import decide_content_language, NoAgreeableContentLanguageError
accept_language_headers = ["en-GB;q=0.8", "nb-NO;q=0.9"]
supported_languages = ["en-GB", "en", "nb-NO", "nb", "en-US"]
try:
content_language = decide_decide_language(accept_language_headers, supported_languages)
except NoAgreeableLanguageError:
print("No agreeable language found.")
# Handle error, by returning e.g. 406 Not Acceptable
% pipx install poetry==1.2.0
% pipx install nox==2022.8.7
% pipx inject nox nox-poetry==1.0.1
% git clone https://github.com/Informasjonsforvaltning/content-negotiation.git
% cd content-negotiation
% pyenv install 3.8.13
% pyenv install 3.9.13
% pyenv install 3.10.6
% pyenv local 3.8.13 3.9.13 3.10.6
% poetry install
% nox
% nox -rs tests
You can enter into Pdb by passing --pdb
to pytest:
% nox -rs tests -- --pdb --log-cli-level=DEBUG
You can set breakpoints directly in code by using the function breakpoint()
.
FAQs
A library for deciding content-type based on media ranges in HTTP Accept headers.
We found that content-negotiation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.