HTTP POST helper that sends JSON and returns response body.
(url: str, json_body: str)
| 66 | |
| 67 | |
| 68 | def post_raw_json(url: str, json_body: str) -> str: |
| 69 | """HTTP POST helper that sends JSON and returns response body.""" |
| 70 | req = urllib.request.Request( |
| 71 | url, |
| 72 | data=json_body.encode('utf-8'), |
| 73 | headers={'Content-Type': 'application/json'}, |
| 74 | method='POST' |
| 75 | ) |
| 76 | |
| 77 | try: |
| 78 | with urllib.request.urlopen(req, timeout=30) as response: |
| 79 | return response.read().decode('utf-8') |
| 80 | except urllib.error.HTTPError as e: |
| 81 | error_body = e.read().decode('utf-8') if e.fp else str(e) |
| 82 | raise Exception(f"HTTP {e.code}: {error_body}") |
| 83 | |
| 84 | |
| 85 | def keystore_new_key(rpc_url: str, nickname: str, password: str) -> str: |
no outgoing calls
no test coverage detected