卷曲-如何捕捉空响应

时间:2019-05-09 02:02:11

标签: curl lua

返回空响应时,cURL似乎不调用writefuntion 在空响应上,不会调用responseHandler。 那我如何才能得到空的答复?

 local cURL = require("cURL")

  function responseHandler(data)
        print(data)
  end

  local headers = {
    "Accept: text/*",
    "Accept-Language: en",
    "Accept-Charset: iso-8859-1,*,utf-8",
    "Cache-Control: no-cache"
  }

  local url = 'http://mydomain/path'

  c = cURL.easy{
    url            = url
    ssl_verifypeer = false,
    ssl_verifyhost = false,
    httpheader     = headers,
    writefunction  = function(data)
        responseHandler(data)
    end
  }

  c:perform()

0 个答案:

没有答案
相关问题