1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: check (mut f Foo) syntax

This commit is contained in:
yuyi
2020-05-17 19:51:18 +08:00
committed by GitHub
parent b138cadbcb
commit 7f4cf08516
87 changed files with 492 additions and 480 deletions

View File

@@ -9,7 +9,7 @@ mut:
}
[inline]
pub fn (r mut Request) parse_request(s string, headers *C.phr_header_t, max_headers int) int {
pub fn (mut r Request) parse_request(s string, headers *C.phr_header_t, max_headers int) int {
method_len := u64(0)
path_len := u64(0)
minor_version := 0
@@ -33,7 +33,7 @@ pub fn (r mut Request) parse_request(s string, headers *C.phr_header_t, max_head
}
[inline]
pub fn (r mut Request) parse_request_path(s string) int {
pub fn (mut r Request) parse_request_path(s string) int {
method_len := u64(0)
path_len := u64(0)
@@ -50,7 +50,7 @@ pub fn (r mut Request) parse_request_path(s string) int {
}
[inline]
pub fn (r mut Request) parse_request_path_pipeline(s string) int {
pub fn (mut r Request) parse_request_path_pipeline(s string) int {
method_len := u64(0)
path_len := u64(0)

View File

@@ -10,13 +10,13 @@ mut:
}
[inline]
pub fn (r mut Response) http_ok() &Response {
pub fn (mut r Response) http_ok() &Response {
r.buf += cpy_str(r.buf, "HTTP/1.1 200 OK\r\n")
return r
}
[inline]
pub fn (r mut Response) header(k, v string) &Response {
pub fn (mut r Response) header(k, v string) &Response {
r.buf += cpy_str(r.buf, k)
r.buf += cpy_str(r.buf, ": ")
r.buf += cpy_str(r.buf, v)
@@ -25,7 +25,7 @@ pub fn (r mut Response) header(k, v string) &Response {
}
[inline]
pub fn (r mut Response) header_date() &Response {
pub fn (mut r Response) header_date() &Response {
r.buf += cpy_str(r.buf, "Date: ")
r.buf += cpy(r.buf, r.date, 29)
r.buf += cpy_str(r.buf, "\r\n")
@@ -33,13 +33,13 @@ pub fn (r mut Response) header_date() &Response {
}
[inline]
pub fn (r mut Response) header_server() &Response {
pub fn (mut r Response) header_server() &Response {
r.buf += cpy_str(r.buf, "Server: V\r\n")
return r
}
[inline]
pub fn (r mut Response) content_type(s string) &Response {
pub fn (mut r Response) content_type(s string) &Response {
r.buf += cpy_str(r.buf, "Content-Type: ")
r.buf += cpy_str(r.buf, s)
r.buf += cpy_str(r.buf, "\r\n")
@@ -47,19 +47,19 @@ pub fn (r mut Response) content_type(s string) &Response {
}
[inline]
pub fn (r mut Response) plain() &Response {
pub fn (mut r Response) plain() &Response {
r.buf += cpy_str(r.buf, "Content-Type: text/plain\r\n")
return r
}
[inline]
pub fn (r mut Response) json() &Response {
pub fn (mut r Response) json() &Response {
r.buf += cpy_str(r.buf, "Content-Type: application/json\r\n")
return r
}
[inline]
pub fn (r mut Response) body(body string) {
pub fn (mut r Response) body(body string) {
r.buf += cpy_str(r.buf, "Content-Length: ")
r.buf += C.u64toa(r.buf, body.len)
r.buf += cpy_str(r.buf, "\r\n\r\n")
@@ -67,27 +67,27 @@ pub fn (r mut Response) body(body string) {
}
[inline]
pub fn (r mut Response) http_404() {
pub fn (mut r Response) http_404() {
r.buf += cpy_str(r.buf, 'HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\n\r\n')
}
[inline]
pub fn (r mut Response) http_405() {
pub fn (mut r Response) http_405() {
r.buf += cpy_str(r.buf, 'HTTP/1.1 405 Method Not Allowed\r\nContent-Length: 0\r\n\r\n')
}
[inline]
pub fn (r mut Response) http_500() {
pub fn (mut r Response) http_500() {
r.buf += cpy_str(r.buf, 'HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n')
}
[inline]
pub fn (r mut Response) raw(response string) {
pub fn (mut r Response) raw(response string) {
r.buf += cpy_str(r.buf, response)
}
[inline]
pub fn (r mut Response) end() int {
pub fn (mut r Response) end() int {
n := int(r.buf - r.buf_start)
if C.write(r.fd, r.buf_start, n) != n {
return -1