|
1 | 1 | #lang typed/racket |
2 | 2 |
|
3 | | -(require typed/net/url) |
| 3 | +(require typed/net/url |
| 4 | + typed/racket/date) |
4 | 5 |
|
5 | 6 | (provide (all-defined-out)) |
6 | 7 |
|
|
57 | 58 | [#:struct response |
58 | 59 | ([code : Natural] |
59 | 60 | [message : Bytes] |
60 | | - [seconds : Natural] |
| 61 | + [seconds : Real] |
61 | 62 | [mime : (Option Bytes)] |
62 | 63 | [headers : (Listof Header)] |
63 | | - [output : (-> Output-Port Void)])] |
| 64 | + [output : (-> Output-Port Any)])] |
64 | 65 | [response/full |
65 | 66 | (-> Natural |
66 | 67 | Bytes |
67 | | - Number |
| 68 | + Real |
68 | 69 | (Option Bytes) |
69 | 70 | (Listof Header) |
70 | 71 | (Listof Bytes) |
71 | 72 | Response)] |
72 | 73 | [response/output |
73 | | - (-> (-> Output-Port Void) |
| 74 | + (-> (-> Output-Port Any) |
74 | 75 | [#:code Natural] |
75 | 76 | [#:message Bytes] |
76 | | - [#:seconds Number] |
| 77 | + [#:seconds Real] |
77 | 78 | [#:mime-type (Option Bytes)] |
78 | 79 | [#:headers (Listof Header)] |
79 | 80 | Response)] |
80 | 81 | [TEXT/HTML-MIME-TYPE Bytes]) |
81 | 82 |
|
| 83 | +;; For backwards compatability: |
| 84 | +;; these bindings are not and never were |
| 85 | +;; exported by web-server/http, |
| 86 | +;; but they were exported by previous versions of |
| 87 | +;; typed/web-server/http based on net/cookie. |
82 | 88 |
|
83 | | -(require/typed/provide net/cookie |
84 | | - [#:opaque Cookie cookie?] |
85 | | - [#:opaque Cookie-Name cookie-name?] |
86 | | - [#:opaque Cookie-Value cookie-value?] |
87 | | - [#:opaque Valid-Domain valid-domain?]) |
| 89 | +(require (only-in "../net/cookies/server.rkt" |
| 90 | + Cookie |
| 91 | + cookie?) |
| 92 | + (only-in "../net/cookies/common.rkt" |
| 93 | + cookie-name? |
| 94 | + cookie-value? |
| 95 | + [domain-value? valid-domain?])) |
88 | 96 |
|
89 | | -(require/typed/provide web-server/http/cookie |
90 | | - [make-cookie |
91 | | - (-> Cookie-Name Cookie-Value |
92 | | - [#:comment (Option String)] |
93 | | - [#:domain (Option Valid-Domain)] |
94 | | - [#:max-age (Option Natural)] |
95 | | - [#:path (Option String)] |
96 | | - [#:expires (Option String)] |
97 | | - [#:secure? (Option Boolean)] |
98 | | - Cookie)] |
99 | | - [cookie->header |
100 | | - (-> Cookie |
101 | | - Header)]) |
| 97 | +(define-type Cookie-Name String) |
| 98 | +(define-type Cookie-Value String) |
| 99 | +(define-type Valid-Domain String) |
| 100 | + |
| 101 | +(provide (all-from-out "../net/cookies/server.rkt") |
| 102 | + (all-from-out "../net/cookies/common.rkt") |
| 103 | + Cookie-Name |
| 104 | + Cookie-Value |
| 105 | + Valid-Domain) |
| 106 | + |
| 107 | +(require/typed/provide |
| 108 | + web-server/http/cookie |
| 109 | + [make-cookie |
| 110 | + (-> String String |
| 111 | + [#:comment Any] |
| 112 | + [#:domain (Option String)] |
| 113 | + [#:max-age (Option Natural)] |
| 114 | + [#:path (Option String)] |
| 115 | + [#:expires (Option (U date String))] |
| 116 | + [#:extension (Option String)] |
| 117 | + ;; yes, these are really different |
| 118 | + ;; than for typed/net/cookies/server |
| 119 | + [#:secure? Any] |
| 120 | + [#:http-only? Any] |
| 121 | + Cookie)] |
| 122 | + [cookie->header |
| 123 | + (-> Cookie |
| 124 | + Header)]) |
102 | 125 |
|
103 | 126 | (require/typed/provide web-server/http/id-cookie |
104 | 127 | [make-id-cookie |
105 | | - (-> Cookie-Name |
| 128 | + (-> String |
106 | 129 | Bytes |
107 | | - Cookie-Value |
| 130 | + String |
108 | 131 | [#:path (Option String)] |
| 132 | + [#:expires (Option date)] |
| 133 | + [#:max-age (Option Exact-Positive-Integer)] |
| 134 | + [#:domain (Option String)] |
| 135 | + [#:extension (Option String)] |
| 136 | + ;; yes, these are really different |
| 137 | + ;; than for typed/net/cookies/server |
| 138 | + [#:secure? Any] |
| 139 | + [#:http-only? Any] |
109 | 140 | Cookie)] |
110 | 141 | [request-id-cookie |
111 | | - (-> Cookie-Name |
| 142 | + (-> String |
112 | 143 | Bytes |
113 | 144 | Request |
114 | | - #:timeout Number |
115 | | - (Option Cookie-Value))] |
| 145 | + [#:timeout Number] |
| 146 | + [#:shelf-life Real] |
| 147 | + (Option String))] |
| 148 | + [valid-id-cookie? |
| 149 | + (-> Any ;; yes, this is really Any |
| 150 | + #:name String |
| 151 | + #:key Bytes |
| 152 | + [#:timeout Number] |
| 153 | + [#:shelf-life Real] |
| 154 | + (Option String))] |
116 | 155 | [logout-id-cookie |
117 | | - (-> Cookie-Name |
| 156 | + (-> String |
118 | 157 | [#:path (Option String)] |
| 158 | + [#:domain (Option String)] |
119 | 159 | Cookie)] |
120 | 160 | [make-secret-salt/file |
121 | 161 | (-> Path-String |
|
125 | 165 | [#:struct client-cookie |
126 | 166 | ([name : String] |
127 | 167 | [value : String] |
128 | | - [domain : (Option Valid-Domain)] |
| 168 | + [domain : (Option String)] |
129 | 169 | [path : (Option String)])] |
130 | 170 | [request-cookies |
131 | 171 | (-> Request |
|
139 | 179 | Response)] |
140 | 180 | [permanently Redirection-Status] |
141 | 181 | [temporarily Redirection-Status] |
| 182 | + [temporarily/same-method Redirection-Status] |
142 | 183 | [see-other Redirection-Status]) |
143 | 184 |
|
144 | 185 | (require/typed/provide web-server/http/basic-auth |
|
170 | 211 | (-> Any ;;; it should be `xexpr?`ed value, but `Any` also works well. |
171 | 212 | [#:code Natural] |
172 | 213 | [#:message Bytes] |
173 | | - [#:seconds Number] |
| 214 | + [#:seconds Real] |
174 | 215 | [#:mime-type (Option Bytes)] |
175 | 216 | [#:headers (Listof Header)] |
176 | 217 | [#:cookies (Listof Cookie)] |
|
0 commit comments