github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/starlib/net/starlarkhttp/README.md (about)

     1  ## default_client
     2  
     3  `default_client` is a constant for the default client implementation.
     4  
     5  ### client·do
     6  
     7  `c.do(req)` sends the HTTP request and returns an HTTP response, as per the client.
     8  
     9  | Parameter | Type | Description |
    10  | --------- | ---- | ----------- |
    11  | req | http.request | Request to send. |
    12  
    13  ## get
    14  
    15  `get(url)` sends a GET requests and returns an HTTP response with the default client.
    16  
    17  | Parameter | Type | Description |
    18  | --------- | ---- | ----------- |
    19  | url | string | URL of request. |
    20  
    21  ## head
    22  
    23  `head(url)` sends a HEAD request to the URL and returns an HTTP response.
    24  
    25  | Parameter | Type | Description |
    26  | --------- | ---- | ----------- |
    27  | url | string | URL of request. |
    28  
    29  ## post
    30  
    31  `post(url, body)` sends a POST request to the URL with the provided body and returns an HTTP response.
    32  
    33  | Parameter | Type | Description |
    34  | --------- | ---- | ----------- |
    35  | url | string | URL of request. |
    36  | body | string, bytes, io.reader | Body of request. |
    37  
    38  ## client
    39  
    40  `client(do)` creates a new client.
    41  Clients are responsible for taking a request and returning a response.
    42  Custom clients could be used to change behaviour for every request. 
    43  They should usually wrap a `go` client like `http.default_client` to continue the request.
    44  
    45  | Parameter | Type | Description |
    46  | --------- | ---- | ----------- |
    47  | do | function | Function that accepts a `request` and returns a `response`. |
    48  
    49  ## request
    50  
    51  `request(method, url, body)` creates a new request.
    52  
    53  | Parameter | Type | Description |
    54  | --------- | ---- | ----------- |
    55  | method | string | HTTP method of request. |
    56  | url | string | URL of request. |
    57  | body | string, bytes, io.reader | Body of request. |
    58  
    59  ## errors
    60  
    61  - `err_not_supported`
    62  - `err_missing_boundary`
    63  - `err_not_multipart`
    64  - `err_body_not_allowed`
    65  - `err_hijacked`
    66  - `err_content_length`
    67  - `err_abort_handler`
    68  - `err_body_read_after_close`
    69  - `err_handler_timeout`
    70  - `err_line_too_long`
    71  - `err_missing_file`
    72  - `err_no_cookie`
    73  - `err_no_location`
    74  - `err_server_closed`
    75  - `err_skip_alt_protocol`
    76  - `err_use_last_response`