erlang http linux curl 返回空的问题


curl 返回结果为空,但是相同的url在浏览器上正常返回

可能原因是erlang 编写的http服务器返回结果没有添加http头


将内容添加Http头代码如下

encode_http_bin(List) -> 
        Head = io_lib:format("HTTP/1.1 200 OK\r\n" "Content-Type: text/plain\r\n" "Content-Length: ~p\r\n\r\n, lenght(List)),
        <<(list_to_binary(Head))/binary, (list_to_binary(List))/binary>>.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章