Skip to main content

Extension of Python HTTP `requests` with verbose logging using `logging-fortified`.

Project description


Work In Progress

Extension of Python HTTP requests with verbose logging using logging-fortified, and robust handling for Downloading files containing JSON, CSV, and XML data formats and Streaming.

Important Note

This Python project is a refactoring of requests-mv-integration for the purpose of general usage intent.

Work In Progress

The following still needs to be performed for this Python project:

  • Unit-testing: This project will be switching over to using Python native Unit testing framework unittest.

  • More concise documentation is required.

  • Travis CI

  • Badges



License Status


PyPI Package latest release Supported versions


pip install requests_fortified


requests-fortified is an extension of the Python package requests and it is used for handling all HTTP requests including APIs in REST and SOAP, screen scrapping, and handling response downloads in JSON, XML, and CSV.



from requests_fortified import (
request_download = RequestsFortifiedDownload(logger_level=logging.DEBUG)

result = \
        request_label="REST Countries"

json_rest_countries = result.json()



$ python3 examples/

run-examples requests-fortified
rm -fR _tmp/*.json
'Logger file path: ./tmp/log_1526043820.json'
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "NOTE", "name": "requests_fortified", "version": "0.1.0", "message": "debug"}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "INFO", "name": "requests_fortified", "version": "0.1.0", "message": "START"}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Start"}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Start: Details", "Disk:": {"path": "/", "total": "232.62 GB", "used": "134.44 GB", "free": "97.94 GB", "percent": 57}, "Mem": {"total": "16.00 GB", "used": "12.50 GB", "free": "147.59 KB", "shared": "0 B", "buffers": "0 B", "cached": "0 B"}, "allow_redirects": true, "build_request_curl": true, "cookie_payload": null, "request_auth": null, "request_cert": null, "request_data": null, "request_headers": {"Content-Type": "application/json", "User-Agent": "(requests-fortified/0.1.0, Python/3.6.5)"}, "request_json": null, "request_label": "REST Countries", "request_method": "GET", "request_params": null, "request_retry": {"timeout": 60, "tries": 3, "delay": 10}, "request_url": "", "stream": false, "timeout": null, "verify": true}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Start", "request_label": "REST Countries", "request_retry_excps": ["ConnectTimeout", "ReadTimeout", "Timeout"], "request_retry_http_status_codes": [500, 502, 503, 504, 429], "timeout": null}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Attempt", "attempts": 1, "delay": 10, "request_label": "REST Countries", "request_url": "", "timeout": 60, "tries": 3}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Session: Details", "cookie_payload": {}, "request_label": "REST Countries"}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Details", "request_data": "", "request_headers": {"Content-Type": "application/json", "User-Agent": "(requests-fortified/0.1.0, Python/3.6.5)"}, "request_label": "REST Countries", "request_method": "GET", "request_params": {}, "request_url": "", "timeout": 60}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "NOTE", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Curl", "request_curl": "curl --verbose -X GET -H \'Content-Type: application/json\' -H \'User-Agent: (requests-fortified/0.1.0, Python/3.6.5)\' --connect-timeout 60 -L \'\'", "request_label": "REST Countries", "request_method": "GET"}\n',
    '{"asctime": "2018-05-11 06:03:26 -0700", "levelname": "DEBUG", "name": "", "version": "0.1.0", "message": "Session Request: Details", "allow_redirects": true, "headers": {"Content-Type": "application/json", "User-Agent": "(requests-fortified/0.1.0, Python/3.6.5)"}, "method": "GET", "timeout": 60, "url": "", "verify": true}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Response: Details", "http_status_code": 200, "http_status_desc": "Request fulfilled, document follows", "http_status_type": "Successful", "response_headers": {"Date": "Fri, 11 May 2018 13:03:27 GMT", "Content-Type": "application/json;charset=utf-8", "Transfer-Encoding": "chunked", "Connection": "keep-alive", "Set-Cookie": "__cfduid=d46030914d4b01044c167b67bbca43b951526043807; expires=Sat, 11-May-19 13:03:27 GMT; path=/;; HttpOnly", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET", "Access-Control-Allow-Headers": "Accept, X-Requested-With", "Cache-Control": "public, max-age=86400", "Expect-CT": "max-age=604800, report-uri=\\"\\"", "Server": "cloudflare", "CF-RAY": "4194d881fc146bd4-SJC", "Content-Encoding": "gzip"}}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Cookie Payload", "cookie_payload": {"__cfduid": "d46030914d4b01044c167b67bbca43b951526043807"}, "request_label": "REST Countries"}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Try Send Request: Is Return Response: Checking", "request_url": ""}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Try Send Request: Is Return Response: Valid", "request_url": ""}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "INFO", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Finished", "request_time_msecs": 569}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "DEBUG", "name": "requests_fortified", "version": "0.1.0", "message": "REST Countries: Usage", "Disk:": {"path": "/", "total": "232.62 GB", "used": "134.44 GB", "free": "97.94 GB", "percent": 57}, "Mem": {"total": "16.00 GB", "used": "12.50 GB", "free": "145.89 KB", "shared": "0 B", "buffers": "0 B", "cached": "0 B"}}\n',
    '{"asctime": "2018-05-11 06:03:27 -0700", "levelname": "INFO", "name": "requests_fortified", "version": "0.1.0", "message": "COMPLETED", "connection": "<requests.adapters.HTTPAdapter object at 0x1043b11d0>", "cookies": "<RequestsCookieJar[<Cookie __cfduid=d46030914d4b01044c167b67bbca43b951526043807 for>]>", "elapsed": "0:00:00.286022", "encoding": "utf-8", "headers": "{\'Date\': \'Fri, 11 May 2018 13:03:27 GMT\', \'Content-Type\': \'application/json;charset=utf-8\', \'Transfer-Encoding\': \'chunked\', \'Connection\': \'keep-alive\', \'Set-Cookie\': \'__cfduid=d46030914d4b01044c167b67bbca43b951526043807; expires=Sat, 11-May-19 13:03:27 GMT; path=/;; HttpOnly\', \'Access-Control-Allow-Origin\': \'*\', \'Access-Control-Allow-Methods\': \'GET\', \'Access-Control-Allow-Headers\': \'Accept, X-Requested-With\', \'Cache-Control\': \'public, max-age=86400\', \'Expect-CT\': \'max-age=604800, report-uri=\\"\\"\', \'Server\': \'cloudflare\', \'CF-RAY\': \'4194d881fc146bd4-SJC\', \'Content-Encoding\': \'gzip\'}", "history": [], "raw": "<urllib3.response.HTTPResponse object at 0x1043b1dd8>", "reason": "", "request": "<PreparedRequest [GET]>", "status_code": 200, "url": ""}\n',
        'alpha2Code': 'AF',
        'alpha3Code': 'AFG',
        'altSpellings': ['AF', 'Afġānistān'],
        'area': 652230.0,
        'borders': ['IRN', 'PAK', 'TKM', 'UZB', 'TJK', 'CHN'],
        'callingCodes': ['93'],
        'capital': 'Kabul',
        'cioc': 'AFG',
        'currencies': [
            {'code': 'AFN', 'name': 'Afghan afghani', 'symbol': '؋'},
        'demonym': 'Afghan',
        'flag': '',
        'gini': 27.8,
        'languages': [
                'iso639_1': 'ps',
                'iso639_2': 'pus',
                'name': 'Pashto',
                'nativeName': 'پښتو',
                'iso639_1': 'uz',
                'iso639_2': 'uzb',
                'name': 'Uzbek',
                'nativeName': 'O\u02bbzbek',
                'iso639_1': 'tk',
                'iso639_2': 'tuk',
                'name': 'Turkmen',
                'nativeName': 'Türkmen',
        'latlng': [33.0, 65.0],
        'name': 'Afghanistan',
        'nativeName': 'افغانستان',
        'numericCode': '004',
        'population': 27657145,
        'region': 'Asia',
        'regionalBlocs': [
                'acronym': 'SAARC',
                'name': 'South Asian Association for Regional Cooperation',
                'otherAcronyms': [],
                'otherNames': [],
        'subregion': 'Southern Asia',
        'timezones': ['UTC+04:30'],
        'topLevelDomain': ['.af'],
        'translations': {
            'br': 'Afeganistão',
            'de': 'Afghanistan',
            'es': 'Afganistán',
            'fa': 'افغانستان',
            'fr': 'Afghanistan',
            'hr': 'Afganistan',
            'it': 'Afghanistan',
            'ja': 'アフガニスタン',
            'nl': 'Afghanistan',
            'pt': 'Afeganistão',


  • class RequestsFortified – Base class using requests with retry functionality and verbose logging.

  • class RequestsFortifiedDownload – Download file handling.

  • class RequestsFortifiedUpload – Upload file handling.


requests-fortified module is built upon Python 3 and has dependencies upon several Python modules available within Python Package Index PyPI.

make install


python3 -m pip uninstall --yes --no-input -r requirements.txt
python3 -m pip install --upgrade -r requirements.txt


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

requests-fortified-0.3.1.tar.gz (54.1 kB view hashes)

Uploaded Source

Built Distribution

requests_fortified-0.3.1-py3-none-any.whl (39.2 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