Skip to main content

HTTP client (httpx) with native yaml support.

Project description

PyPI version Coverage Status Code style: black

httpxy

HTTP client with yaml support

Adds minor convenience features to the excellent httpx library which aims to make working with yaml easier and safer.

Installation

pip install httpxy

Features

  • Always use safe_load(). DONE
  • Response objects have a response.yaml() for deserializing YAML to a dict. DONE
  • Automatic serialization of objects to yaml. TODO
  • Automatic deserializing of yaml to python objects/classes/models. TODO
  • Works with multiple yaml packages. TODO

Examples

Deserialize directly from Response objects.

Equivalent to response.json().

import httpxy
from pprint import pprint

response = httpxy.get("https://mockbin.org/request", headers={"accept": "application/yaml"})

dict_from_yaml = response.yaml()

pprint(dict_from_yaml, sort_dicts=False, depth=1)
    {'startedDateTime': '2021-03-06T19:54:03.157Z',
     'clientIPAddress': '99.99.999.999',
     'method': 'GET',
     'url': 'https://mockbin.org/request',
     'httpVersion': 'HTTP/1.1',
     'cookies': None,
     'headers': {...},
     'queryString': {},
     'postData': {...},
     'headersSize': 559,
     'bodySize': 0}
print(response.text)
    startedDateTime: '2021-03-06T19:54:03.157Z'
    clientIPAddress: 99.99.999.999
    method: GET
    url: 'https://mockbin.org/request'
    httpVersion: HTTP/1.1
    cookies:
    headers:
      host: mockbin.org
      connection: close
      accept-encoding: gzip
      x-forwarded-proto: http
      cf-visitor: '{"scheme":"https"}'
      accept: application/yaml
      user-agent: python-httpx/0.17.0
    queryString: {}
    postData:
      mimeType: application/octet-stream
      text: ""
      params: []
    headersSize: 559
    bodySize: 0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpxy-0.0.0a1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

httpxy-0.0.0a1-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page