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

EXPORTS

15       convert_request_date(DateString) -> ErlDate|bad_date
16
17              Types:
18
19                 DateString = string()
20                 ErlDate = {{Year,Month,Date},{Hour,Min,Sec}}
21                 Year = Month = Date = Hour = Min = Sec = integer()
22
23              convert_request_date/1  converts  DateString  to the Erlang date
24              format. DateString must be in one  of  the  three  date  formats
25              defined in RFC 2616.
26
27       create_etag(FileInfo) -> Etag
28
29              Types:
30
31                 FileInfo = file_info()
32                 Etag = string()
33
34              create_etag/1  calculates  the Etag for a file from its size and
35              time for last modification. FileInfo is a record defined in ker‐
36              nel/include/file.hrl.
37
38       day(NthDayOfWeek) -> DayOfWeek
39
40              Types:
41
42                 NthDayOfWeek = 1-7
43                 DayOfWeek = string()
44
45              day/1  converts the day of the week (NthDayOfWeek) from an inte‐
46              ger (1-7) to an abbreviated string, that is:
47
48              1 = "Mon", 2 = "Tue", ..., 7 = "Sat".
49
50       decode_hex(HexValue) -> DecValue
51
52              Types:
53
54                 HexValue = DecValue = string()
55
56              Converts the hexadecimal value HexValue into its decimal equiva‐
57              lent (DecValue).
58
59       flatlength(NestedList) -> Size
60
61              Types:
62
63                 NestedList = list()
64                 Size = integer()
65
66              flatlength/1 computes the size of the possibly nested list Nest‐
67              edList, which can contain binaries.
68
69       hexlist_to_integer(HexString) -> Number
70
71              Types:
72
73                 Number = integer()
74                 HexString = string()
75
76              hexlist_to_integer converts the hexadecimal value  of  HexString
77              to an integer.
78
79       integer_to_hexlist(Number) -> HexString
80
81              Types:
82
83                 Number = integer()
84                 HexString = string()
85
86              integer_to_hexlist/1  returns  a string representing Number in a
87              hexadecimal form.
88
89       lookup(ETSTable,Key) -> Result
90       lookup(ETSTable,Key,Undefined) -> Result
91
92              Types:
93
94                 ETSTable = ets_table()
95                 Key = term()
96                 Result = term() | undefined | Undefined
97                 Undefined = term()
98
99              lookup extracts {Key,Value} tuples from ETSTable and returns the
100              Value  associated with Key. If ETSTable is of type bag, only the
101              first Value associated with Key is  returned.  lookup/2  returns
102              undefined and lookup/3 returns Undefined if no Value is found.
103
104       lookup_mime(ConfigDB,Suffix)
105       lookup_mime(ConfigDB,Suffix,Undefined) -> MimeType
106
107              Types:
108
109                 ConfigDB = ets_table()
110                 Suffix = string()
111                 MimeType = string() | undefined | Undefined
112                 Undefined = term()
113
114              lookup_mime  returns  the  MIME  type associated with a specific
115              file suffix as specified in the file mime.types (located in  the
116              config directory).
117
118       lookup_mime_default(ConfigDB,Suffix)
119       lookup_mime_default(ConfigDB,Suffix,Undefined) -> MimeType
120
121              Types:
122
123                 ConfigDB = ets_table()
124                 Suffix = string()
125                 MimeType = string() | undefined | Undefined
126                 Undefined = term()
127
128              lookup_mime_default returns the MIME type associated with a spe‐
129              cific file suffix as specified in the mime.types  file  (located
130              in  the   config  directory).  If  no appropriate association is
131              found, the value of DefaultType is returned.
132
133       message(StatusCode,PhraseArgs,ConfigDB) -> Message
134
135              Types:
136
137                 StatusCode = 301 | 400 | 403 | 404 | 500 | 501 | 504
138                 PhraseArgs = term()
139                 ConfigDB = ets_table
140                 Message = string()
141
142              message/3 returns an informative HTTP 1.1 status string in HTML.
143              Each StatusCode requires a specific PhraseArgs:
144
145                301:
146                  string(): A URL pointing at the new document position.
147
148                400 | 401 | 500:
149                  none (no PhraseArgs).
150
151                403 | 404:
152                  string(): A Request-URI as described in RFC 2616.
153
154                501:
155                  {Method,RequestURI,HTTPVersion}:  The  HTTP Method, Request-
156                  URI, and HTTP-Version as defined in RFC 2616.
157
158                504:
159                  string(): A string describing why the service  was  unavail‐
160                  able.
161
162       month(NthMonth) -> Month
163
164              Types:
165
166                 NthMonth = 1-12
167                 Month = string()
168
169              month/1  converts  the month NthMonth as an integer (1-12) to an
170              abbreviated string, that is:
171
172              1 = "Jan", 2 = "Feb", ..., 12 = "Dec".
173
174       multi_lookup(ETSTable,Key) -> Result
175
176              Types:
177
178                 ETSTable = ets_table()
179                 Key = term()
180                 Result = [term()]
181
182              multi_lookup extracts all {Key,Value} tuples  from  an  ETSTable
183              and returns all Values associated with Key in a list.
184
185       reason_phrase(StatusCode) -> Description
186
187              Types:
188
189                 StatusCode  =  100| 200 | 201 | 202 | 204 | 205 | 206 | 300 |
190                 301 | 302 | 303 | 304 | 400 | 401 | 402 | 403 | 404 |  405  |
191                 406 | 410 411 | 412 | 413 | 414 415 | 416 | 417 | 500 | 501 |
192                 502 | 503 | 504 | 505
193                 Description = string()
194
195              reason_phrase returns Description of an HTTP 1.1 StatusCode, for
196              example, 200 is "OK" and 201 is "Created". For more information,
197              see RFC 2616.
198
199       rfc1123_date() -> RFC1123Date
200       rfc1123_date({{YYYY,MM,DD},{Hour,Min,Sec}}) -> RFC1123Date
201
202              Types:
203
204                 YYYY = MM = DD = Hour = Min = Sec = integer()
205                 RFC1123Date = string()
206
207              rfc1123_date/0 returns the current  date  in  RFC  1123  format.
208              rfc_date/1  converts  the  date  in the Erlang format to the RFC
209              1123 date format.
210
211       split(String,RegExp,N) -> SplitRes
212
213              Types:
214
215                 String = RegExp = string()
216                 SplitRes = {ok, FieldList} | {error, errordesc()}
217                 Fieldlist = [string()]
218                 N = integer
219
220              split/3 splits String in  N  chunks  using  RegExp.  split/3  is
221              equivalent  to  regexp:split/2 with the exception that N defines
222              the maximum number of fields in FieldList.
223
224       split_script_path(RequestLine) -> Splitted
225
226              Types:
227
228                 RequestLine = string()
229                 Splitted = not_a_script | {Path, PathInfo, QueryString}
230                 Path = QueryString = PathInfo = string()
231
232              split_script_path/1  is  equivalent  to  split_path/1  with  one
233              exception. If the longest possible path is not a regular, acces‐
234              sible, and executable file, then not_a_script is returned.
235
236       split_path(RequestLine) -> {Path,QueryStringOrPathInfo}
237
238              Types:
239
240                 RequestLine = Path = QueryStringOrPathInfo = string()
241
242              split_path/1 splits RequestLine in a file reference (Path),  and
243              a  QueryString  or a PathInfo string as specified in RFC 2616. A
244              QueryString is isolated from Path with a question mark  (?)  and
245              PathInfo  with a slash (/). In the case of a QueryString, every‐
246              thing before ? is a Path and everything after  ?  is  a  QueryS‐
247              tring.  In  the  case of a PathInfo, RequestLine is scanned from
248              left-to-right on the hunt for longest possible Path being a file
249              or a directory. Everything after the longest possible Path, iso‐
250              lated with a /, is regarded as PathInfo. The resulting  Path  is
251              decoded using decode_hex/1 before delivery.
252
253       strip(String) -> Stripped
254
255              Types:
256
257                 String = Stripped = string()
258
259              strip/1  removes any leading or trailing linear white space from
260              the string. Linear white space is to be read as  horizontal  tab
261              or space.
262
263       suffix(FileName) -> Suffix
264
265              Types:
266
267                 FileName = Suffix = string()
268
269              suffix/1  is  equivalent to filename:extension/1 with the excep‐
270              tion that Suffix is returned without a leading dot (.).
271

SEE ALSO

273       httpd(3)
274
275
276
277Ericsson AB                      inets 6.5.2.4                   httpd_util(3)
Impressum