|
490 | 490 | " \"Send request with `urlrequest`, converting result to json if `return_json`\"\n", |
491 | 491 | " req = urlrequest(url, verb, headers, route=route, query=query, data=data, json_data=json_data)\n", |
492 | 492 | " if debug: debug(req)\n", |
| 493 | + " \n", |
| 494 | + " if route and route.get('archive_format', None):\n", |
| 495 | + " return urlread(req, decode=False, return_json=False, return_headers=return_headers)\n", |
| 496 | + " \n", |
493 | 497 | " return urlread(req, return_json=return_json, return_headers=return_headers)" |
494 | 498 | ] |
495 | 499 | }, |
| 500 | + { |
| 501 | + "cell_type": "markdown", |
| 502 | + "metadata": {}, |
| 503 | + "source": [ |
| 504 | + "Test [ghapi.actions.download_artifact](https://docs.github.com/rest/reference/actions#download-an-artifact)" |
| 505 | + ] |
| 506 | + }, |
| 507 | + { |
| 508 | + "cell_type": "code", |
| 509 | + "execution_count": null, |
| 510 | + "metadata": {}, |
| 511 | + "outputs": [], |
| 512 | + "source": [ |
| 513 | + "\n", |
| 514 | + "url = \"https://github.com/fastai/ghapi/archive/refs/tags/0.1.15.zip\"\n", |
| 515 | + "header={'Accept': 'application/vnd.github.v3+json'}\n", |
| 516 | + "route={'artifact_id': 1234, 'archive_format': 'zip'} \n", |
| 517 | + "\n", |
| 518 | + "res = urlsend(url, \"get\", headers=header, route=route)\n", |
| 519 | + "assert type(res) is bytes\n", |
| 520 | + "\n", |
| 521 | + "def _org_urlsend(url, verb, headers=None, route=None, query=None, data=None, json_data=True,\n", |
| 522 | + " return_json=True, return_headers=False, debug=None):\n", |
| 523 | + " req = urlrequest(url, verb, headers, route=route, query=query, data=data, json_data=json_data)\n", |
| 524 | + " if debug: debug(req)\n", |
| 525 | + " return urlread(req, return_json=return_json, return_headers=return_headers)\n", |
| 526 | + "\n", |
| 527 | + "test_fail(_org_urlsend, args=dict(url=url, verb=\"get\", headers=header, route=route), msg=\"'utf-8' codec can't decode\")" |
| 528 | + ] |
| 529 | + }, |
496 | 530 | { |
497 | 531 | "cell_type": "code", |
498 | 532 | "execution_count": null, |
|
0 commit comments