httpd_util(3erl)
๐ NAME ๐
Okay so bestie, welcome to httpd_util(3erl) โ the Erlang Module Definition for httpd_util, aka miscellaneous utility functions to be used when implementing Erlang web server API modules. ๐
โจ
โจ DESCRIPTION โจ
This module provides the Erlang web server API module programmer with miscellaneous utility functions. Itโs giving โlittle toolbox, big main character energyโ for real. ๐ซถ
๐จ Note ๐จ
Note bestie: this module is only recommended for using with httpd โ for other cases it should be considered as deprecated. Like, vibe check: do not treat it as your non-httpd era icon. ๐ญ๐
๐ฆ EXPORTS ๐ฆ
Okay so hereโs the full exports menu, no skipping, no summarizing โ literally every one. ๐
convert_request_date(DateString) -> ErlDate|bad_date
Types:
DateString = string()ErlDate = calendar:datetime()
Lowkey iconic: convert_request_date/1 converts DateString to the Erlang date format. No cap, DateString must be in one of the three date formats defined in RFC 2616. ๐๏ธโจ
create_etag(FileInfo) -> Etag
Types:
FileInfo = file_info()Etag = string()
create_etag/1 calculates the Etag for a file from its size and time for last modification. FileInfo is a record defined in kernel/include/file.hrl โ iykyk. ๐ฅ
day(NthDayOfWeek) -> DayOfWeek
Types:
NthDayOfWeek = 1-7DayOfWeek = string()
day/1 converts the day of the week (NthDayOfWeek) from an integer (1-7) to an abbreviated string, that is:
1 = "Mon", 2 = "Tue", ..., 7 = "Sat".
decode_hex(HexValue) -> DecValue
Types:
HexValue = DecValue = string()
Converts the hexadecimal value HexValue into its decimal equivalent (DecValue). Cute little base conversion moment. ๐งฎ๐
flatlength(NestedList) -> Size
Types:
NestedList = list()Size = integer()
flatlength/1 computes the size of the possibly nested list NestedList, which can contain binaries. Itโs giving โlist inside a list inside a listโ realness. ๐ชโจ
hexlist_to_integer(HexString) -> Number
Types:
Number = integer()HexString = string()
hexlist_to_integer converts the hexadecimal value of HexString to an integer. Slay, hex math. ๐
integer_to_hexlist(Number) -> HexString
Types:
Number = integer()HexString = string()
integer_to_hexlist/1 returns a string representing Number in a hexadecimal form. Obsessed with the round trip. ๐
lookup โ the lookup/2 and lookup/3 moment ๐ซ
lookup(ETSTable,Key) -> Result
lookup(ETSTable,Key,Undefined) -> Result
Types:
ETSTable = ets_table()Key = term()Result = term() | undefined | UndefinedUndefined = term()
lookup extracts {Key,Value} tuples from ETSTable and returns the Value associated with Key. If ETSTable is of type bag, only the first Value associated with Key is returned. lookup/2 returns undefined and lookup/3 returns Undefined if no Value is found. ๐ต๏ธโโ๏ธโจ
lookup_mime โ both signatures, no cap ๐
lookup_mime(ConfigDB,Suffix)
lookup_mime(ConfigDB,Suffix,Undefined) -> MimeType
Types:
ConfigDB = ets_table()Suffix = string()MimeType = string() | undefined | UndefinedUndefined = term()
lookup_mime returns the MIME type associated with a specific file suffix as specified in the file mime.types (located in the config directory). ๐๏ธ๐
lookup_mime_default โ the fallback bestie ๐ธ
lookup_mime_default(ConfigDB,Suffix)
lookup_mime_default(ConfigDB,Suffix,Undefined) -> MimeType
Types:
ConfigDB = ets_table()Suffix = string()MimeType = string() | undefined | UndefinedUndefined = term()
lookup_mime_default returns the MIME type associated with a specific file suffix as specified in the mime.types file (located in the config directory). If no appropriate association is found, the value of DefaultType is returned. Ngl, that default is doing important work. โจ
message(StatusCode,PhraseArgs,ConfigDB) -> Message
Types:
StatusCode = 301 | 400 | 403 | 404 | 500 | 501 | 504PhraseArgs = term()ConfigDB = ets_tableMessage = string()
message/3 returns an informative HTTP 1.1 status string in HTML. Each StatusCode requires a specific PhraseArgs:
301:string(): A URL pointing at the new document position. ๐400 | 401 | 500:none (noPhraseArgs). ๐ โโ๏ธ403 | 404:string(): A Request-URI as described in RFC 2616. ๐501:{Method,RequestURI,HTTPVersion}: The HTTP Method, Request-URI, and HTTP-Version as defined in RFC 2616. ๐ ๏ธ504:string(): A string describing why the service was unavailable. ๐ญ
month(NthMonth) -> Month
Types:
NthMonth = 1-12Month = string()
month/1 converts the month NthMonth as an integer (1-12) to an abbreviated string, that is:
1 = "Jan", 2 = "Feb", ..., 12 = "Dec".
multi_lookup(ETSTable,Key) -> Result
Types:
ETSTable = ets_table()Key = term()Result = [term()]
multi_lookup extracts all {Key,Value} tuples from an ETSTable and returns all Values associated with Key in a list. It ate, honestly. ๐๐
reason_phrase(StatusCode) -> Description
Types:
StatusCode = 100 | 200 | 201 | 202 | 204 | 205 | 206 | 300 | 301 | 302 | 303 | 304 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 501 | 502 | 503 | 504 | 505Description = string()
reason_phrase returns Description of an HTTP 1.1 StatusCode, for example, 200 is "OK" and 201 is "Created". For more information, see RFC 2616. ๐โจ
rfc1123_date โ current date and date conversion ๐ฐ๏ธ
rfc1123_date() -> RFC1123Date
rfc1123_date(Date) -> RFC1123Date
Types:
Date = calendar:datetime()RFC1123Date = string()
rfc1123_date/0 returns the current date in RFC 1123 format. rfc_date/1 converts the date in the Erlang format to the RFC 1123 date format. Iconic date formatting behavior, fr. โจ
split(String,RegExp,N) -> SplitRes
Types:
String = RegExp = string()SplitRes = {ok, FieldList} | {error, errordesc()}Fieldlist = [string()]N = integer
split/3 splits String in N chunks using RegExp. split/3 is equivalent to regexp:split/2 with the exception that N defines the maximum number of fields in FieldList. ๐ช
split_script_path(RequestLine) -> Split
Types:
RequestLine = string()Split = not_a_script | {Path, PathInfo, QueryString}Path = QueryString = PathInfo = string()
split_script_path/1 is equivalent to split_path/1 with one exception. If the longest possible path is not a regular, accessible, and executable file, then not_a_script is returned. Not me checking for executables like a little detective. ๐ง
split_path(RequestLine) -> {Path,QueryStringOrPathInfo}
Types:
RequestLine = Path = QueryStringOrPathInfo = string()
split_path/1 splits RequestLine in a file reference (Path), and a QueryString or a PathInfo string as specified in RFC 2616. A QueryString is isolated from Path with a question mark (?) and PathInfo with a slash (/). In the case of a QueryString, everything before ? is a Path and everything after ? is a QueryString. In the case of a PathInfo, RequestLine is scanned from left-to-right on the hunt for longest possible Path being a file or a directory. Everything after the longest possible Path, isolated with a /, is regarded as PathInfo. The resulting Path is decoded using decode_hex/1 before delivery. Main character energy for path parsing, honestly. ๐งญ๐
strip(String) -> Stripped
Types:
String = Stripped = string()
strip/1 removes any leading or trailing linear white space from the string. Linear white space is to be read as horizontal tab or space. Clean girl aesthetic but for strings. ๐งผโจ
suffix(FileName) -> Suffix
Types:
FileName = Suffix = string()
suffix/1 is equivalent to filename:extension/1 with the exception that Suffix is returned without a leading dot (.). Cute little dotless moment. ๐
๐ SEE ALSO ๐
๐ซถ Cute little sign-off: this page is brought to you by Ericsson AB, version inets 8.3.1.2, and the manual name httpd_util(3erl). Thatโs the whole footer vibe, bestie. ๐๐ periodt.
๐ฆ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 ยท Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms