haproxytech / haproxy-lua-http

Simple Lua HTTP helper && client for use with HAProxy.
Apache License 2.0
56 stars 23 forks source link

How to parse response body on GET/POST method #11

Closed hellracer closed 3 years ago

hellracer commented 3 years ago

Hey,

Good day, may I know how can I get the response body of the request? any help is much appreciated thanks!

anezirovic commented 3 years ago

From your question, tt's not entirely clear if you need payload from the request or content of the response (after you made client request with haproxy-lua-http); nevertheless

1) To obtain request body (for POST/PUT requests) you need to call request.parse() or request.parse_multipart(), which will fill in "requst.data" 2) After calling response = http.get() or similar from your Lua code, the response body will be saved in the "response.content" field.

hellracer commented 3 years ago

@anezirovic thanks it's working! I need the content of the response parsing "response.content" as you mentioned fix my issue, I think it should be worth mentioning in the example, just my 0.2$ cheers!