Software /
code /
prosody
Annotate
teal-src/net/http/parser.d.tl @ 12763:d26eefe98d09
util.dbuffer: Add efficient shortcuts for discard() in certain cases
If the buffer is already empty, nothing to do. If we're throwing away the
whole buffer, we can just empty it and avoid read_chunk() (which in turn
may collapse()). These shortcuts are much more efficient.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 11 Oct 2022 11:37:55 +0100 |
parent | 12609:a8eb838fc6cf |
rev | line source |
---|---|
12609
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local record httpstream |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 feed : function(httpstream, string) |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local type sink_cb = function () |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local record httppacket |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 enum http_method |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 "HEAD" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 "GET" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 "POST" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 "PUT" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 "DELETE" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 "OPTIONS" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 -- etc |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 method : http_method |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 record url_details |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 path : string |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 query : string |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 url : url_details |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 path : string |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 enum http_version |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 "1.0" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 "1.1" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 httpversion : http_version |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 headers : { string : string } |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 body : string | boolean |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 body_sink : sink_cb |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 chunked : boolean |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 partial : boolean |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 local enum error_conditions |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 "cancelled" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 "connection-closed" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 "certificate-chain-invalid" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 "certificate-verify-failed" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 "connection failed" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 "invalid-url" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 "unable to resolve service" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 local type success_cb = function (httppacket) |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 local type error_cb = function (error_conditions) |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 local enum stream_mode |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 "client" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 "server" |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
54 local record lib |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
55 new : function (success_cb, error_cb, stream_mode) : httpstream |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 end |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 |
a8eb838fc6cf
net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 return lib |