http.hrl 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. %% Copyright (c) 2011, Loïc Hoguin <essen@dev-extend.eu>
  2. %%
  3. %% Permission to use, copy, modify, and/or distribute this software for any
  4. %% purpose with or without fee is hereby granted, provided that the above
  5. %% copyright notice and this permission notice appear in all copies.
  6. %%
  7. %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. %% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. %% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. %% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. -type http_method() :: 'OPTIONS' | 'GET' | 'HEAD'
  15. | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | string().
  16. -type http_uri() :: '*' | {absoluteURI, http | https, Host::string(),
  17. Port::integer() | undefined, Path::string()}
  18. | {scheme, Scheme::string(), string()}
  19. | {abs_path, string()} | string().
  20. -type http_version() :: {Major::integer(), Minor::integer()}.
  21. -type http_header() :: 'Cache-Control' | 'Connection' | 'Date' | 'Pragma'
  22. | 'Transfer-Encoding' | 'Upgrade' | 'Via' | 'Accept' | 'Accept-Charset'
  23. | 'Accept-Encoding' | 'Accept-Language' | 'Authorization' | 'From' | 'Host'
  24. | 'If-Modified-Since' | 'If-Match' | 'If-None-Match' | 'If-Range'
  25. | 'If-Unmodified-Since' | 'Max-Forwards' | 'Proxy-Authorization' | 'Range'
  26. | 'Referer' | 'User-Agent' | 'Age' | 'Location' | 'Proxy-Authenticate'
  27. | 'Public' | 'Retry-After' | 'Server' | 'Vary' | 'Warning'
  28. | 'Www-Authenticate' | 'Allow' | 'Content-Base' | 'Content-Encoding'
  29. | 'Content-Language' | 'Content-Length' | 'Content-Location'
  30. | 'Content-Md5' | 'Content-Range' | 'Content-Type' | 'Etag'
  31. | 'Expires' | 'Last-Modified' | 'Accept-Ranges' | 'Set-Cookie'
  32. | 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive'
  33. | 'Proxy-Connection' | string().
  34. -type http_headers() :: list({http_header(), string()}).
  35. %% -type http_cookies() :: term(). %% @todo
  36. -type http_status() :: non_neg_integer() | string().
  37. -record(http_req, {
  38. %% Transport.
  39. socket = undefined :: undefined | inet:socket(),
  40. transport = undefined :: undefined | module(),
  41. connection = keepalive :: keepalive | close,
  42. %% Request.
  43. method = 'GET' :: http_method(),
  44. version = {1, 1} :: http_version(),
  45. peer = undefined :: undefined | {Address::inet:ip_address(), Port::port_number()},
  46. host = undefined :: undefined | cowboy_dispatcher:path_tokens(),
  47. raw_host = undefined :: undefined | string(),
  48. path = undefined :: undefined | '*' | cowboy_dispatcher:path_tokens(),
  49. raw_path = undefined :: undefined | string(),
  50. qs_vals = undefined :: undefined | list({Name::string(), Value::string() | true}),
  51. raw_qs = undefined :: undefined | string(),
  52. bindings = undefined :: undefined | cowboy_dispatcher:bindings(),
  53. headers = [] :: http_headers(),
  54. %% cookies = undefined :: undefined | http_cookies() %% @todo
  55. %% Request body.
  56. body_state = waiting :: waiting | done,
  57. %% Response.
  58. resp_state = locked :: locked | waiting | done
  59. }).