package http:client

⌘K
Ctrl+K
or
/

    Overview

    package provides a very simple (for now) HTTP/1.1 client.

    Index

    Constants (0)

    This section is empty.

    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Body_Error ¶

    Body_Error :: enum int {
    	None, 
    	No_Length, 
    	Invalid_Length, 
    	Too_Long, 
    	Scan_Failed, 
    	Invalid_Chunk_Size, 
    	Invalid_Trailer_Header, 
    }
    Related Procedures With Returns

    Body_Plain ¶

    Body_Plain :: string
     

    Any non-special body, could have been a chunked body that has been read in fully automatically. Depending on the return value for 'was_allocation' of the parse function, this is either an allocated string that you should delete or a slice into the body.

    Body_Type ¶

    Body_Type :: union {
    	string, 
    	map[string]string, 
    	Body_Error, 
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    Body_Url_Encoded ¶

    Body_Url_Encoded :: map[string]string
     

    A URL encoded body, map, keys and values are fully allocated on the allocator given to the parsing function, And should be deleted by you.

    Error ¶

    Related Procedures With Returns

    Request ¶

    Request :: struct {
    	method:  http.Method,
    	headers: http.Headers,
    	cookies: [dynamic]http.Cookie,
    	body:    bytes.Buffer,
    }
    Related Procedures With Parameters

    Request_Error ¶

    Request_Error :: enum int {
    	Ok, 
    	Invalid_Response_HTTP_Version, 
    	Invalid_Response_Method, 
    	Invalid_Response_Header, 
    	Invalid_Response_Cookie, 
    }

    Response ¶

    Response :: struct {
    	status:    http.Status,
    	// headers and cookies should be considered read-only, after a response is returned.
    	headers:   http.Headers,
    	cookies:   [dynamic]http.Cookie,
    	_socket:   Communication,
    	_body:     bufio.Scanner,
    	_body_err: Body_Error,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    SSL_Error ¶

    SSL_Error :: enum int {
    	Ok, 
    	Controlled_Shutdown, 
    	Fatal_Shutdown, 
    	SSL_Write_Failed, 
    }

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    body_destroy ¶

    body_destroy :: proc(body: Body_Type, was_allocation: bool) {…}
     

    Frees the memory allocated by parsing the body. was_allocation is returned by the body parsing procedure.

    get ¶

    get :: proc(target: string, allocator := context.allocator) -> (Response, Error) {…}

    request ¶

    request :: proc(request: ^Request, target: string, allocator := context.allocator) -> (res: Response, err: Error) {…}

    request_destroy ¶

    request_destroy :: proc(r: ^Request) {…}
     

    Destroys the request. Header keys and values that the user added will have to be deleted by the user. Same with any strings inside the cookies.

    request_init ¶

    request_init :: proc(r: ^Request, method: http.Method = http.Method.Get, allocator := context.allocator) {…}
     

    Initializes the request with sane defaults using the given allocator.

    response_body ¶

    response_body :: proc(res: ^Response, max_length: int = -1, allocator := context.allocator) -> (body: Body_Type, was_allocation: bool, err: Body_Error) {…}
     

    Retrieves the response's body, can only be called once. Free the returned body using body_destroy().

    response_destroy ¶

    response_destroy :: proc(res: ^Response, body: runtime.Maybe($T=Body_Type) = nil, was_allocation: bool = false) {…}
     

    Frees the response, closes the connection. Optionally pass the response_body returned 'body' and 'was_allocation' to destroy it too.

    with_json ¶

    with_json :: proc(r: ^Request, v: any, opt: encoding_json.Marshal_Options = {}) -> encoding_json.Marshal_Error {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-10 (vendor "odin") Linux_amd64 @ 2024-10-30 12:34:52.772253788 +0000 UTC