lua socket POST

前端 未结 1 624
一整个雨季
一整个雨季 2020-12-15 21:55

I have a hard time using lua socket generic POST. I\'m trying to POST to a web along with a body. But the body output i got is 1. Here\'s my code



        
相关标签:
1条回答
  • 2020-12-15 22:11

    http.request has two forms, The simple form downloads a URL using the GET or POST method and is based on strings.

    http.request(url [, body])
    

    The generic form performs any HTTP method and is LTN12 based.

    http.request{
      url = string,
      [sink = LTN12 sink,]
      [method = string,]
      [headers = header-table,]
      [source = LTN12 source],
      [step = LTN12 pump step,]
      [proxy = string,]
      [redirect = boolean,]
      [create = function]
    }
    

    You are using the generic form, and according to the document, the first return value is supposed to be 1.

    In case of failure, the function returns nil followed by an error message. If successful, the simple form returns the response body as a string, followed by the response status code, the response headers and the response status line. The generic function returns the same information, except the first return value is just the number 1 (the body goes to the sink).

    0 讨论(0)
提交回复
热议问题