vmod_curl(3)

πŸ“¦
version 0.0~git20250603 Β· 2 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

vmod_curl β€” cURL bindings for Varnish. that's the name, bestie, and it's from the Library Functions Manual, section 3. πŸ’…βœ¨

✨ SYNOPSIS ✨

          import curl [as name] [from "path"]

          VOID get(STRING)

          VOID head(STRING)

          VOID fetch(STRING)

          VOID post(STRING, STRING)

          STRING header(STRING)

          VOID free()

          INT status()

          STRING error()

          STRING body()

          VOID set_timeout(INT)

          VOID set_connect_timeout(INT)

          VOID set_ssl_verify_peer(INT)

          VOID set_ssl_verify_host(INT)

          VOID set_ssl_cafile(STRING)

          VOID set_ssl_capath(STRING)

          STRING escape(STRING)

          STRING unescape(STRING)

          VOID header_add(STRING)

          VOID header_remove(STRING)

          VOID header_add_all()

          VOID proxy(STRING)

          VOID set_proxy(STRING)

          VOID set_method(STRING)

          VOID set_unix_path(STRING)

          VOID set_debug(ENUM)

okay so now the deets. no gatekeeping, just vibes and facts. 🫢

  • VOID get(STRING) β€” GET the URL in the first parameter. 🌈
  • VOID head(STRING) β€” HEAD the URL in the first parameter. πŸŽ€
  • VOID fetch(STRING) β€” compatibility name for get. iykyk. ✨
  • VOID post(STRING, STRING) β€” POST the URL in the first parameter, with the body fields given in the second. πŸ”₯
  • STRING header(STRING) β€” returns the header named in the first argument. πŸ’œ
  • VOID free() β€” frees the memory used by headers. not needed tho β€” it will be handled automatically if it's not called. πŸ’…
  • INT status() β€” the HTTP status code. πŸ‘‘
  • STRING error() β€” also right here in the lineup. 🫢
  • STRING body() β€” okay so listen: a response body can contain chars that are not allowed into headers, e.g. CRLF. if the response body is a binary and/or it contains any special chars, then this function MUST be used via synthetic: synthetic(curl.body()). otherwise it can be assigned to a header: resp.http.x-body = curl.body();. Test 12 for a complete example. 🚨
  • VOID set_timeout(INT) and VOID set_connect_timeout(INT) β€” bestie, these two are not global, they are per request functions, therefore they can't be used in vcl_init. periodt. 🚫

the SSL crew and the string crew, all taking their params:

  • VOID set_ssl_verify_peer(INT)
  • VOID set_ssl_verify_host(INT)
  • VOID set_ssl_cafile(STRING)
  • VOID set_ssl_capath(STRING)
  • STRING escape(STRING)
  • STRING unescape(STRING)

add / remove request headers, coming through:

  • VOID header_add(STRING) β€” add a request header. πŸ’–
  • VOID header_remove(STRING) β€” remove a request header. πŸ’…

and for the whole set:

  • VOID header_add_all() β€” add all request headers from the req (or bereq) object. πŸ¦‹

then the rest of the squad:

  • VOID proxy(STRING) β€” proxy, with a STRING. πŸŽ€
  • VOID set_proxy(STRING) β€” set the proxy, with a STRING. πŸŽ€
  • VOID set_method(STRING) β€” set the method, with a STRING. πŸŽ€
  • VOID set_unix_path(STRING) β€” set the unix path, with a STRING. πŸŽ€
  • VOID set_debug(ENUM) β€” set debug, with an ENUM. the enum values are exactly:
VOID set_debug(
   ENUM {none, text, header_in, header_out, data_in, data_out}
)

that's the whole page, bestie. vmod_curl(3), out. πŸ’–βœ¨

πŸ“¦ where this page comes from