Skip to main content

This is asyhttp, a simple module to perform asynchronous HTTP requests using asyncio and aiohttp.

It provides a trivial way to perform a set of async HTTP requests.

Features

  • Proxy support

  • Custom headers

  • Allow redirects

  • Use TLS

How to use loop()

asyhttp loop() accepts some **kwargs

  • urls a set of dictionaries, each dict represent an HTTP request.

  • proxy proxt URL, str (optional)

  • process_out a user defined function that can be used to process the response of each HTTP request. It will be called by the async function that perform each HTTP request, as soon as the response arrive. (optional)

Getting started

from asyhttp import loop

requests = [    {'url':'http://exam.ple/page.html', 'method':'GET'},
                {'url':'http://exam.ple/page.html', 'method':'POST', 'body' : 'blabla'}
]
loop(urls=requests)

Use cases

asyhttp loop can be useful to write quick bruteforces against vulnerable systems or as a core for tools like dirfister.

An early version of this code comes from https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html

Docs

Process HTTP responses

By default, asyhttp loop print on stdout HTTP status code and reason for each response received. You can override its default behavior writing custom code to process the response your HTTP requests. Your code has to be written in a function and passed to loop as a kwarg called process_out. That function will be called by the async function that perform each of your HTTP requests, as soon as the response arrive.

In your custom code you can process: - url: url of the HTTP request - return_code - reason - resp_body

Example

from asyhttp import loop
requests = [{'url':'http://exam.ple/page.html', 'method':'GET'}]
loop(urls=requests)

Example

from asyhttp import loop
def process_output(url,return_code,reason,resp_body):
        if return_code == 200:
                sys.stdout.write("url")

requests = [{'url':'http://exam.ple/page.html', 'method':'GET'}]
loop(urls=requests,process_out=process_output)

asyhttp loop’s **kwargs

  • urls

  • process_out

  • proxy

  • verify_tls

  • redirects

Supported HTTP methods

  • GET

  • POST

  • HEAD

HTTP requests format

{'method':'GET', 'url':'http://exam.ple/page.html'}
{'method':'POST', 'url':'http://exam.ple/page.html','body':'blablabl=balbal'}
{'url':'http://exam.ple/page.html', 'method':'GET', 'headers' : 'X-Custom-Header:YEAH'}

Proxy support

loop(urls=url_dict_list,proxy="http://127.0.0.1:8080")

Custom headers

To add HTTP headers to a request, pass them as a dict.

{'url':'http://exam.ple/page.html', 'method':'GET', 'headers' : {'User-agent':'YEAH'}}

Allow redirects

False by default

loop(urls=requests,process_out=process_response,redirects=True)

Verify TLS

False by default

loop(urls=requests,process_out=process_response,verify_tls=True)

Download files

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

Source Distribution

asyhttp-0.1.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file asyhttp-0.1.tar.gz.

File metadata

  • Download URL: asyhttp-0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for asyhttp-0.1.tar.gz
Algorithm Hash digest
SHA256 161a553070ae39d089cb0b6bb9275df6dcc3ddc7770d69e24c52621f89886554
MD5 a9f51acfab5cce48bbd5f96cb8f38da4
BLAKE2b-256 b44def69507743872d32ac89d4a8307b35cbddc0c4f809093b275e6d19815817

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2

1 file

This release

0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page