package land:http interface http-types { // HTTP Status Codes type http-status-code = u16 // HTTP Request Methods, use uppercase type http-method = string // HTTP Request Headers type http-headers = list> // HTTP URI type http-uri = string // HTTP Request Body type http-body-handle = u32 // HTTP Request record request{ method: http-method, uri: http-uri, headers: http-headers, body: option } // HTTP Response record response{ status: http-status-code, headers: http-headers, body: option } // HTTP errors returned by the runtime. enum request-error { // The request failed due to a network error. network-error, // The request failed due to a timeout. timeout, // The request failed due to a invalid url. invalid-url, // The request failed due to a forbidden destination. destination-not-allowed, // The request failed due to over requests limit. too-many-requests, // The request failed due to invalid request invalid-request, } // Fetch redirect policy enum redirect-policy { // Follow redirects. follow, // Do not follow redirects. error, // Follow redirects, but do not follow redirects to cross-origin destinations. manual, } // HTTP request option record request-options{ // The request timeout in milliseconds. timeout: u32, // Follow redirects. redirect: redirect-policy, } }