Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httplink

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httplink

Library for parsing RFC 8288 "Link" HTTP headers

  • 0.2.0
  • PyPI
  • Socket score

Maintainers
1

Python (>= 3.6) library for parsing RFC 8288 <https://tools.ietf.org/html/rfc8288>__ HTTP Link headers. Python 2 is not supported <https://github.com/joernheissler/httplink/pull/2>__.

.. code-block:: python3

from httplink import parse_link_header
result = parse_link_header('''
   <https://example.com/foo/index.html>; rel=index;
   foo*=UTF-8'en'b%c3%a5r, </path#frag>;rel="what ever"
''')

## Target URL:
print(result['index'].target)
# https://example.com/foo/index.html

## Set of link relations:
print(result['index'].rel)
# {'index'}

## Decoded attribute value:
print(result['index']['foo'])
# bår

## Raw undecoded attributes:
print(result['index'].attributes)
# [('rel', 'index'), ('foo*', "UTF-8'en'b%c3%a5r")]

## Iterate over all links:
for link in result.links:
    print(link.rel, link.target)
# {'index'} https://example.com/foo/index.html
# {'ever', 'what'} /path#frag

Multiple Link headers can be parsed at the same time if you concatenate them with ,.

Redundant white space and comma delimiters are ignored.

["key"]-access is always case-insensitive.

Keywords

FAQs


Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc