maxwell v2.2.2 Maxwell.Adapter.Util

Utils for Adapter

Summary

Functions

Check req_headers has transfer-encoding: chunked

Add content-type to headers if don't have; Add content-length to headers if not chunked

Converts the headers map to a list of tuples

Encode multipart form

Fetch the first element from stream

Append path and query string to url

Functions

chunked?(conn)

Check req_headers has transfer-encoding: chunked.

file_header_transform(chunked, conn)

Add content-type to headers if don't have; Add content-length to headers if not chunked

header_serialize(headers)

Converts the headers map to a list of tuples.

  • headers - Map.t, for example: %{"content-type" => "application/json"}

Examples

iex> headers_serialize(%{"content-type" => "application/json"})
 [{"content-type", "application/json"}]
multipart_encode(conn, multiparts)

Encode multipart form.

stream_iterate(filepath)

Fetch the first element from stream.

url_serialize(url, path, query_string, type \\ :string)

Append path and query string to url

  • url - conn.url
  • path - conn.path
  • query - conn.query
  • type - :char_list or :string, default is :string

Examples

#http://example.com/home?name=foo
iex> url_serialize("http://example.com", "/home", %{"name" => "foo"})