You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A nice way for doing sanity checking and also for checking what the formatted output of for example the request uri is. Like this, in the Request module, but fully featured and property-tested:
letasCurl(req :Request):string =letcmd _ = Some ["curl"]letprintHeaders _ =
Some ["-i"]letmethod req =if req.method <> Get then["-X"; req.method.ToString()]|> Some
else None
leturi(req :Request)=letub= UriBuilder req.url
ub.Query <- Impl.getQueryString Encoding.UTF8 req
Some [ ub.Uri.ToString()]letform(req :Request)=match req.body with| BodyForm form ->
form
|> List.choose (function| NameValue (name, value)->
Some (name, value)|_->
None)|> List.map (fun(name,value)->["-d"; sprintf "\"%s=%s\"" name value ])|> List.concat
|> Some
|_->
None
letbasic(req:Request)=match req.headers |> Map.tryFind "Authorization"with| None -> None
| Some (Authorization value)when value.StartsWith("Basic")->match value.Split(' ')with|[| kind; base64Value |]->// horrible hack; not calculating the base64 encoding until last responsible moment is the right fixletconverted= UTF8.toString (Convert.FromBase64String base64Value)
Some ["-u"; sprintf "\"%s\"" converted ]|_->
None
|_->
None
[ cmd
printHeaders
method
uri
form
basic
]|> List.map (fun f -> f req)|> List.filter Option.isSome
|> List.map Option.get
|> List.concat
|> String.concat ""
The text was updated successfully, but these errors were encountered:
A nice way for doing sanity checking and also for checking what the formatted output of for example the request uri is. Like this, in the
Request
module, but fully featured and property-tested:The text was updated successfully, but these errors were encountered: