HTTP methods are defined in the HttpCore module:
HttpMethod* = enum ## the requested HttpMethod
HttpHead = "HEAD" ## Asks for the response identical to the one that
## would correspond to a GET request, but without
## the response body.
HttpGet = "GET" ## Retrieves the specified resource.
HttpPost = "POST" ## Submits data to be processed to the identified
## resource. The data is included in the body of
## the request.
HttpPut = "PUT" ## Uploads a representation of the specified
## resource.
HttpDelete = "DELETE" ## Deletes the specified resource.
HttpTrace = "TRACE" ## Echoes back the received request, so that a
## client
## can see what intermediate servers are adding or
## changing in the request.
HttpOptions = "OPTIONS" ## Returns the HTTP methods that the server
## supports for specified address.
HttpConnect = "CONNECT" ## Converts the request connection to a transparent
## TCP/IP tunnel, usually used for proxies.
HttpPatch = "PATCH" ## Applies partial modifications to a resource.
The fetch method in JavaScript supports all HTTP methods, even those that don't exist - the value is passed as text.
The fetch implementation in the jsfetch module only supports basic HTTP methods:
func newfetchOptions*(metod = HttpGet; body: cstring = nil;
mode = fmCors; credentials = fcSameOrigin; cache = fchDefault; referrerPolicy = frpNoReferrerWhenDowngrade;
keepalive = false; redirect = frFollow; referrer = "client".cstring; integrity = "".cstring,
headers: Headers = newHeaders()): FetchOptions =
## Constructor for `FetchOptions`.
result = FetchOptions(
body: if metod notin {HttpHead, HttpGet}: body else: nil,
mode: cstring($mode), credentials: cstring($credentials), cache: cstring($cache), referrerPolicy: cstring($referrerPolicy),
keepalive: keepalive, redirect: cstring($redirect), referrer: referrer, integrity: integrity, headers: headers,
metod: (case metod
of HttpHead: "HEAD".cstring
of HttpGet: "GET".cstring
of HttpPost: "POST".cstring
of HttpPut: "PUT".cstring
of HttpDelete: "DELETE".cstring
of HttpPatch: "PATCH".cstring
else: "GET".cstring
)
)
Is this intentional, or just an incomplete implementation? I need the OPTIONS method. I sent a pull request - decide whether full support for HTTP methods in fetch is a good idea.