mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: use http.Response constants instead of strings (#10730)
This commit is contained in:
@@ -22,10 +22,15 @@ fn (mut resp Response) free() {
|
||||
// Formats resp to bytes suitable for HTTP response transmission
|
||||
pub fn (resp Response) bytes() []byte {
|
||||
// TODO: build []byte directly; this uses two allocations
|
||||
return resp.bytestr().bytes()
|
||||
}
|
||||
|
||||
// Formats resp to a string suitable for HTTP response transmission
|
||||
pub fn (resp Response) bytestr() string {
|
||||
// TODO: cookies
|
||||
return ('$resp.version $resp.status_code ${status_from_int(resp.status_code).str()}\r\n' + '${resp.header.render(
|
||||
version: resp.version
|
||||
)}\r\n' + '$resp.text').bytes()
|
||||
)}\r\n' + '$resp.text')
|
||||
}
|
||||
|
||||
// Parse a raw HTTP response into a Response object
|
||||
|
||||
Reference in New Issue
Block a user