99public import Std.Internal.Http.Data.Method
1010public import Std.Internal.Http.Data.Version
1111public import Std.Internal.Http.Data.Headers
12+ public import Std.Internal.Http.Data.URI
1213
1314public section
1415
@@ -40,7 +41,7 @@ structure Request.Head where
4041 /--
4142 The request target/URI indicating the resource being requested
4243 -/
43- uri : String := ""
44+ uri : RequestTarget := .asteriskForm
4445
4546 /--
4647 Collection of HTTP headers for the request (Content-Type, Authorization, etc.)
@@ -88,7 +89,7 @@ instance : Encode .v11 Head where
8889 encode buffer req :=
8990 let buffer := Encode.encode (v := .v11) buffer req.method
9091 let buffer := buffer.writeChar ' '
91- let buffer := buffer.writeString req.uri
92+ let buffer := Encode.encode (v := .v11) buffer req.uri
9293 let buffer := buffer.writeChar ' '
9394 let buffer := Encode.encode (v := .v11) buffer req.version
9495 let buffer := buffer.writeString "\r\n "
@@ -124,9 +125,16 @@ def version (builder : Builder) (version : Version) : Builder :=
124125/--
125126Sets the request target/URI for the request being built
126127-/
127- def uri (builder : Builder) (uri : String ) : Builder :=
128+ def uri (builder : Builder) (uri : RequestTarget ) : Builder :=
128129 { builder with head := { builder.head with uri := uri } }
129130
131+ /--
132+ Sets the request target/URI for the request being built
133+ -/
134+ def uri! (builder : Builder) (uri : String) : Builder :=
135+ let uri := RequestTarget.parse! uri
136+ { builder with head := { builder.head with uri } }
137+
130138/--
131139Sets the headers for the request being built
132140-/
@@ -166,39 +174,39 @@ end Builder
166174/--
167175Creates a new HTTP GET Request with the specified URI
168176-/
169- def get (uri : String ) : Builder :=
177+ def get (uri : RequestTarget ) : Builder :=
170178 new
171179 |>.method .get
172180 |>.uri uri
173181
174182/--
175183Creates a new HTTP POST Request builder with the specified URI.
176184-/
177- def post (uri : String ) : Builder :=
185+ def post (uri : RequestTarget ) : Builder :=
178186 new
179187 |>.method .post
180188 |>.uri uri
181189
182190/--
183191Creates a new HTTP PUT Request builder with the specified URI.
184192-/
185- def put (uri : String ) : Builder :=
193+ def put (uri : RequestTarget ) : Builder :=
186194 new
187195 |>.method .put
188196 |>.uri uri
189197
190198/--
191199Creates a new HTTP DELETE Request builder with the specified URI
192200-/
193- def delete (uri : String ) : Builder :=
201+ def delete (uri : RequestTarget ) : Builder :=
194202 new
195203 |>.method .delete
196204 |>.uri uri
197205
198206/--
199207Creates a new HTTP PATCH Request builder with the specified URI
200208-/
201- def patch (uri : String ) : Builder :=
209+ def patch (uri : RequestTarget ) : Builder :=
202210 new
203211 |>.method .patch
204212 |>.uri uri
@@ -207,33 +215,33 @@ def patch (uri : String) : Builder :=
207215Creates a new HTTP HEAD Request builder with the specified URI.
208216Named `head'` to avoid conflict with the `head` field accessor.
209217-/
210- def head' (uri : String ) : Builder :=
218+ def head' (uri : RequestTarget ) : Builder :=
211219 new
212220 |>.method .head
213221 |>.uri uri
214222
215223/--
216224Creates a new HTTP OPTIONS Request builder with the specified URI.
217- Use `Request.options (String .asteriskForm)` for server-wide OPTIONS.
225+ Use `Request.options (RequestTarget .asteriskForm)` for server-wide OPTIONS.
218226-/
219- def options (uri : String ) : Builder :=
227+ def options (uri : RequestTarget ) : Builder :=
220228 new
221229 |>.method .options
222230 |>.uri uri
223231
224232/--
225233Creates a new HTTP CONNECT Request builder with the specified URI.
226- Typically used with `String .authorityForm` for tunneling.
234+ Typically used with `RequestTarget .authorityForm` for tunneling.
227235-/
228- def connect (uri : String ) : Builder :=
236+ def connect (uri : RequestTarget ) : Builder :=
229237 new
230238 |>.method .connect
231239 |>.uri uri
232240
233241/--
234242Creates a new HTTP TRACE Request builder with the specified URI
235243-/
236- def trace (uri : String ) : Builder :=
244+ def trace (uri : RequestTarget ) : Builder :=
237245 new
238246 |>.method .trace
239247 |>.uri uri
0 commit comments