Darshan Deshmukh Darshan Deshmukh - 1 year ago 114
Python Question

How to check partial response from a http server

My RSS JSON response looks like this

"kind": "demo",
"items": [
"title": "First title",
"comment": "First comment.",
"characteristics": {
"length": "short",
"accuracy": "high",
"followers": ["Jo", "Will"],
"status": "active",

I wanted to fetch partial response in case there is a delay in returning entire body due to any issues

Answer Source

You can use requests library on python. You can easily check for partial response using the following code snippet,

import requests

def get_feed(trials=1):
    response = requests.get('http://example.com/rss')
    if response.status_code == 200:
        # the response is good! do something
    elif response.status_code == 206:
        # partial response... maybe try again,
        if trials > 5:
            # tried 5 times, but no response.
            return None
            return get_feed(trials+1)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download