我有几个执行HTTP POST/GET/HEAD请求的函数.
对于POST请求,我使用:
http:request(post, {Url, [], ContentType, Body}, [], []).
Run Code Online (Sandbox Code Playgroud)
而对于HEAD/GET,我使用:
http:request(Method, {Url, []}, [], [])
Run Code Online (Sandbox Code Playgroud)
如何以独特的方式编写这两个电话?POST请求具有与GET/HEAD请求相关的那两个附加变量.我尝试使用空列表,但我得到了:
** exception error: no function clause matching
Run Code Online (Sandbox Code Playgroud)
非常感谢你
要httpc
仅将调用用于一次,您需要Request
从调用中提取元组,因为这是在使用它们时方法之间的唯一性:
post(URL, ContentType, Body) -> request(post, {URL, [], ContentType, Body}).
get(URL) -> request(get, {URL, []}).
head(URL) -> request(head, {URL, []}).
request(Method, Request) ->
httpc:request(Method, Request, [], []).
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4561 次 |
最近记录: |