Skip to content

Commit 5220914

Browse files
Add headers arg to urljson
1 parent f2ee316 commit 5220914

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

fastcore/net.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ def urlread(url, data=None, headers=None, decode=True, return_json=False, return
127127
return (res,dict(hdrs)) if return_headers else res
128128

129129
# %% ../nbs/03b_net.ipynb
130-
def urljson(url, data=None, timeout=None):
130+
def urljson(url, data=None, timeout=None, headers=None):
131131
"Retrieve `url` and decode json"
132-
res = urlread(url, data=data, timeout=timeout)
132+
res = urlread(url, data=data, timeout=timeout, headers=headers)
133133
return json.loads(res) if res else {}
134134

135135
# %% ../nbs/03b_net.ipynb

nbs/03b_net.ipynb

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"text/markdown": [
192192
"---\n",
193193
"\n",
194-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L64){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
194+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/net.py#L67){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
195195
"\n",
196196
"#### HTTP4xxClientError\n",
197197
"\n",
@@ -202,7 +202,7 @@
202202
"text/plain": [
203203
"---\n",
204204
"\n",
205-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L64){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
205+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/net.py#L67){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
206206
"\n",
207207
"#### HTTP4xxClientError\n",
208208
"\n",
@@ -230,7 +230,7 @@
230230
"text/markdown": [
231231
"---\n",
232232
"\n",
233-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L69){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
233+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/net.py#L72){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
234234
"\n",
235235
"#### HTTP5xxServerError\n",
236236
"\n",
@@ -241,7 +241,7 @@
241241
"text/plain": [
242242
"---\n",
243243
"\n",
244-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/net.py#L69){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
244+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/net.py#L72){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
245245
"\n",
246246
"#### HTTP5xxServerError\n",
247247
"\n",
@@ -347,7 +347,8 @@
347347
"====Error Body====\n",
348348
"{\n",
349349
" \"message\": \"Not Found\",\n",
350-
" \"documentation_url\": \"https://docs.github.com/rest\"\n",
350+
" \"documentation_url\": \"https://docs.github.com/rest\",\n",
351+
" \"status\": \"404\"\n",
351352
"}\n",
352353
"\n"
353354
]
@@ -387,9 +388,9 @@
387388
"outputs": [],
388389
"source": [
389390
"#|export\n",
390-
"def urljson(url, data=None, timeout=None):\n",
391+
"def urljson(url, data=None, timeout=None, headers=None):\n",
391392
" \"Retrieve `url` and decode json\"\n",
392-
" res = urlread(url, data=data, timeout=timeout)\n",
393+
" res = urlread(url, data=data, timeout=timeout, headers=headers)\n",
393394
" return json.loads(res) if res else {}"
394395
]
395396
},
@@ -794,13 +795,6 @@
794795
"from nbdev import nbdev_export\n",
795796
"nbdev_export()"
796797
]
797-
},
798-
{
799-
"cell_type": "code",
800-
"execution_count": null,
801-
"metadata": {},
802-
"outputs": [],
803-
"source": []
804798
}
805799
],
806800
"metadata": {

0 commit comments

Comments
 (0)