1httpd_util(3)              Erlang Module Definition              httpd_util(3)
2
3
4

NAME

6       httpd_util - Miscellaneous utility functions to be used when implement‐
7       ing
8         Erlang web server API modules.
9

DESCRIPTION

11       This module provides the Erlang web server API module  programmer  with
12       miscellaneous utility functions.
13
14   Note:
15       Note  the  module  is only recommended for using with httpd - for other
16       cases it should be considered as deprecated.
17
18

EXPORTS

20       convert_request_date(DateString) -> ErlDate|bad_date
21
22              Types:
23
24                 DateString = string()
25                 ErlDate = calendar:datetime()
26
27              convert_request_date/1 converts DateString to  the  Erlang  date
28              format.  DateString must be in one of the three date formats de‐
29              fined in RFC 2616.
30
31       create_etag(FileInfo) -> Etag
32
33              Types:
34
35                 FileInfo = file_info()
36                 Etag = string()
37
38              create_etag/1 calculates the Etag for a file from its  size  and
39              time for last modification. FileInfo is a record defined in ker‐
40              nel/include/file.hrl.
41
42       day(NthDayOfWeek) -> DayOfWeek
43
44              Types:
45
46                 NthDayOfWeek = 1-7
47                 DayOfWeek = string()
48
49              day/1 converts the day of the week (NthDayOfWeek) from an  inte‐
50              ger (1-7) to an abbreviated string, that is:
51
52              1 = "Mon", 2 = "Tue", ..., 7 = "Sat".
53
54       lookup(ETSTable,Key) -> Result
55       lookup(ETSTable,Key,Undefined) -> Result
56
57              Types:
58
59                 ETSTable = ets_table()
60                 Key = term()
61                 Result = term() | undefined | Undefined
62                 Undefined = term()
63
64              lookup extracts {Key,Value} tuples from ETSTable and returns the
65              Value associated with Key. If ETSTable is of type bag, only  the
66              first  Value  associated  with Key is returned. lookup/2 returns
67              undefined and lookup/3 returns Undefined if no Value is found.
68
69       lookup_mime(ConfigDB,Suffix)
70       lookup_mime(ConfigDB,Suffix,Undefined) -> MimeType
71
72              Types:
73
74                 ConfigDB = ets_table()
75                 Suffix = string()
76                 MimeType = string() | undefined | Undefined
77                 Undefined = term()
78
79              lookup_mime returns the MIME type  associated  with  a  specific
80              file  suffix as specified in the file mime.types (located in the
81              config directory).
82
83       lookup_mime_default(ConfigDB,Suffix)
84       lookup_mime_default(ConfigDB,Suffix,Undefined) -> MimeType
85
86              Types:
87
88                 ConfigDB = ets_table()
89                 Suffix = string()
90                 MimeType = string() | undefined | Undefined
91                 Undefined = term()
92
93              lookup_mime_default returns the MIME type associated with a spe‐
94              cific  file  suffix as specified in the mime.types file (located
95              in the config  directory).  If  no  appropriate  association  is
96              found, the value of DefaultType is returned.
97
98       message(StatusCode,PhraseArgs,ConfigDB) -> Message
99
100              Types:
101
102                 StatusCode = 301 | 400 | 403 | 404 | 500 | 501 | 504
103                 PhraseArgs = term()
104                 ConfigDB = ets_table
105                 Message = string()
106
107              message/3 returns an informative HTTP 1.1 status string in HTML.
108              Each StatusCode requires a specific PhraseArgs:
109
110                301:
111                  string(): A URL pointing at the new document position.
112
113                400 | 401 | 500:
114                  none (no PhraseArgs).
115
116                403 | 404:
117                  string(): A Request-URI as described in RFC 2616.
118
119                501:
120                  {Method,RequestURI,HTTPVersion}: The HTTP  Method,  Request-
121                  URI, and HTTP-Version as defined in RFC 2616.
122
123                504:
124                  string():  A  string describing why the service was unavail‐
125                  able.
126
127       month(NthMonth) -> Month
128
129              Types:
130
131                 NthMonth = 1-12
132                 Month = string()
133
134              month/1 converts the month NthMonth as an integer (1-12)  to  an
135              abbreviated string, that is:
136
137              1 = "Jan", 2 = "Feb", ..., 12 = "Dec".
138
139       multi_lookup(ETSTable,Key) -> Result
140
141              Types:
142
143                 ETSTable = ets_table()
144                 Key = term()
145                 Result = [term()]
146
147              multi_lookup  extracts  all  {Key,Value} tuples from an ETSTable
148              and returns all Values associated with Key in a list.
149
150       reason_phrase(StatusCode) -> Description
151
152              Types:
153
154                 StatusCode = 100 | 200 | 201 | 202 | 204 | 205 | 206 | 300  |
155                 301  |  302 | 303 | 304 | 308 | 400 | 401 | 402 | 403 | 404 |
156                 405 | 406 | 410 | 411 | 412 | 413 | 414 | 415 | 416 |  417  |
157                 500 | 501 | 502 | 503 | 504 | 505
158                 Description = string()
159
160              reason_phrase returns Description of an HTTP 1.1 StatusCode, for
161              example, 200 is "OK" and 201 is "Created". For more information,
162              see RFC 2616.
163
164       rfc1123_date() -> RFC1123Date
165       rfc1123_date(Date) -> RFC1123Date
166
167              Types:
168
169                  Date = calendar:datetime()
170                 RFC1123Date = string()
171
172              rfc1123_date/0  returns  the  current  date  in RFC 1123 format.
173              rfc_date/1 converts the date in the Erlang  format  to  the  RFC
174              1123 date format.
175
176       split(String,RegExp,N) -> SplitRes
177
178              Types:
179
180                 String = RegExp = string()
181                 SplitRes = {ok, FieldList} | {error, errordesc()}
182                 Fieldlist = [string()]
183                 N = integer
184
185              split/3  splits  String  in  N  chunks  using RegExp. split/3 is
186              equivalent to regexp:split/2 with the exception that  N  defines
187              the maximum number of fields in FieldList.
188
189       split_script_path(RequestLine) -> Split
190
191              Types:
192
193                 RequestLine = string()
194                 Split = not_a_script | {Path, PathInfo, QueryString}
195                 Path = QueryString = PathInfo = string()
196
197              split_script_path/1  is  equivalent to split_path/1 with one ex‐
198              ception. If the longest possible path is not a regular, accessi‐
199              ble, and executable file, then not_a_script is returned.
200
201       split_path(RequestLine) -> {Path,QueryStringOrPathInfo}
202
203              Types:
204
205                 RequestLine = Path = QueryStringOrPathInfo = string()
206
207              split_path/1  splits RequestLine in a file reference (Path), and
208              a QueryString or a PathInfo string as specified in RFC  2616.  A
209              QueryString  is  isolated from Path with a question mark (?) and
210              PathInfo with a slash (/). In the case of a QueryString,  every‐
211              thing  before  ?  is  a Path and everything after ? is a QueryS‐
212              tring. In the case of a PathInfo, RequestLine  is  scanned  from
213              left-to-right on the hunt for longest possible Path being a file
214              or a directory. Everything after the longest possible Path, iso‐
215              lated with a /, is regarded as PathInfo
216

SEE ALSO

218       httpd(3)
219
220
221
222Ericsson AB                       inets 9.0.2                    httpd_util(3)
Impressum