Skip to main content

fastrequest fast http requests extension

Project description

fastrequest

A Python C extension module for fast HTTP requests with SSL/TLS support

Installation

To build and install the extension, you just need to run the install.sh script. The script then installs required packages, builds the extension using setuptools and then installs it using pip.

chmod +x install.sh
./install.sh

Example Usage

Just import fastrequest module. It's usage is as easy as ABC!

import fastrequest.http

res = fastrequest.http.get("https://www.google.com")
res.save_to("index.html")

Also, JSON (application/json) responses can be handled easily too.

import json
import fastrequest.http

res = fastrequest.http.get("https://jsonplaceholder.typicode.com/comments?postId=1")

with open("data.json", "w") as fp:
  json.dump(fp, res.json())

Module Reference

HTTPResponse

HTTPResponse is the generic HTTP/HTTPS response object returned from the GET/POST functions.

Pythonic definition of HTTPResponse is as follows,

class HTTPResponse(object):
  def __init__(self, data, size, url=""):
    self.data = data
    self.size = size
    self.url = url

  def text(self):
    return self.data.decode()

  def json(self):
    return json.loads(self.text())

http.get

http.get(url: str[, headers:dict]) -> HTTPResponse

HTTP/GET request function using libcurl as backend.

API Reference

HTTPResponse

HTTPResponse is the generic HTTP/HTTPS response object returned from the GET/POST functions.

The data structure of HTTPResponse object is as follows,

typedef struct {
    PyObject_HEAD
    PyObject *response_size;
    PyObject *response_data;
    PyObject *request_url;
} HTTPResponseObject;

Where

  • response_size is byte-size of the response body (PyLong)
  • response_body is the response body (PyBytes)
  • request_url is the requested URI (PyUnicode)

StringBuffer

StringBuffer is the generic 'string' object implementation to be used in Fast Request API functions.

The data structure of StringBuffer object is as follows,

typedef struct {
    char *buf;
    int_fast64_t index;
    int_fast64_t size;
} StringBuffer;

FastRequestAPI_LibcurlHttpGet

StringBuffer *FastRequestAPI_LibcurlHttpGet(char *url, PyObject *headers)

Send HTTP/GET request to machine with the url specified with optional custom headers. This function uses libcurl as the backend.

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

fastrequest-1.6.3b0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastrequest-1.6.3b0-cp37-cp37m-macosx_10_14_x86_64.whl (23.7 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

File details

Details for the file fastrequest-1.6.3b0.tar.gz.

File metadata

  • Download URL: fastrequest-1.6.3b0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for fastrequest-1.6.3b0.tar.gz
Algorithm Hash digest
SHA256 dd01fa09888e16d8cee83e055286d4f8e5d63d28b5ec5dc882e2da75fa664b51
MD5 19cdb352e962a9ce15a00058b4ebe944
BLAKE2b-256 6438ba3a1275041ce9a17eb4e5c96a215fd40c80a005a2d76b04d33c7cd9b0b5

See more details on using hashes here.

File details

Details for the file fastrequest-1.6.3b0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: fastrequest-1.6.3b0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for fastrequest-1.6.3b0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a1e52394a1b6efc7b0a358ca5db6bcdb3a9a3079a75e037877a60a52609c7bc2
MD5 35e93e0a435247aff195d223faa56f20
BLAKE2b-256 80fa96f4469261169d09c49f2332cc9fb510d7b6f690b4e1be80e69c9f423bb7

See more details on using hashes here.

Supported by

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