Check-in [4b035870ec]
Overview
| Comment: | Make AHTTP timeout= configurable. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
4b035870ec63377c0943aff506ee4640 |
| User & Date: | mario on 2015-05-10 19:12:16 |
| Other Links: | manifest | tags |
Context
|
2015-05-10
| ||
| 19:12 | Create stub plugins/__init__.py in any case. check-in: a6b4b00c41 user: mario tags: trunk | |
| 19:12 | Make AHTTP timeout= configurable. check-in: 4b035870ec user: mario tags: trunk | |
|
2015-05-09
| ||
| 21:41 | Fix super slow requests download for Xiph YP.XML, due to automatic charset detected in requests.text access. Override encoding= now and manually .decode() known "utf-8" charset. check-in: 06fe0ef3db user: mario tags: trunk | |
Changes
Modified ahttp.py from [5620882bf2] to [5b9a02ed1c].
| ︙ | ︙ | |||
49 50 51 52 53 54 55 | }) #-- Retrieve data via HTTP # # Well, it says "get", but it actually does POST and AJAXish GET requests too. # | | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
})
#-- Retrieve data via HTTP
#
# Well, it says "get", but it actually does POST and AJAXish GET requests too.
#
def get(url, params={}, referer="", post=0, ajax=0, binary=0, feedback=None, content=True, verify=False, statusmsg=None, encoding=None, timeout=9.25):
# statusbar info
progress_feedback(url)
# combine headers
headers = {}
if ajax:
headers["X-Requested-With"] = "XMLHttpRequest"
if referer:
headers["Referer"] = (referer if referer else url)
#ifdef BLD_DEBUG
#srcout raise Exception("Simulated HTTP error")
#endif
# read
if post:
log.HTTP("POST", url, params)
r = session.post(url, params=params, headers=headers, timeout=timeout)
else:
log.HTTP("GET"+(" AJAX" if ajax else ""), url, params )
r = session.get(url, params=params, headers=headers, verify=verify, timeout=timeout)
log.HTTP(">>>", r.request.headers );
log.HTTP("<<<", r.headers );
# result
log.INFO("Content-Length", len(r.content) )
statusmsg and progress_feedback(statusmsg)
|
| ︙ | ︙ |