Skip to content

Commit dec1c0b

Browse files
authored
veb: remove commented code in veb_d_new_veb.v (#26124)
1 parent af6f9da commit dec1c0b

1 file changed

Lines changed: 5 additions & 37 deletions

File tree

‎vlib/veb/veb_d_new_veb.v‎

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub fn run_at[A, X](mut global_app A, params RunParams) ! {
2222

2323
// run_new - start a new veb server using the parallel fasthttp backend.
2424
pub fn run_new[A, X](mut global_app A, port int) ! {
25-
// gapp = global_app
2625
if port <= 0 || port > 65535 {
2726
return error('invalid port number `${port}`, it should be between 1 and 65535')
2827
}
@@ -52,35 +51,16 @@ pub fn run_new[A, X](mut global_app A, port int) ! {
5251
server.run() or { panic(err) }
5352
}
5453

55-
// const test_text = 'test'
56-
5754
fn parallel_request_handler[A, X](req fasthttp.HttpRequest) ![]u8 {
58-
/*
59-
if true {
60-
return test_text.bytes()
61-
}
62-
*/
6355
// Get parameters from user_data - copy to avoid use-after-free
6456
params := unsafe { *(&RequestParams(req.user_data)) }
6557
mut global_app := unsafe { &A(params.global_app) }
66-
// println('parallel_request_handler() params.routes=${params.routes}')
67-
// println('global_app=$global_app')
68-
// println('params=$params')
69-
// println('req=$req')
70-
// println('buffer=${req.buffer.bytestr()}')
71-
s := req.buffer.bytestr()
72-
// method := unsafe { tos(&req.buffer[req.method.start], req.method.len) }
73-
// println('method=${method}')
74-
// path := unsafe { tos(&req.buffer[req.path.start], req.path.len) }
75-
// println('path=${path}')
58+
7659
client_fd := req.client_conn_fd
7760

61+
s := req.buffer.bytestr()
7862
// Parse the raw request bytes into a standard `http.Request`.
7963
req2 := http.parse_request_str(s.clone()) or {
80-
eprintln('[veb] Failed to parse request: ${err}')
81-
println('s=')
82-
println(s)
83-
println('==============')
8464
return 'HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\nConnection: close\r\n\r\n'.bytes()
8565
}
8666
// Create and populate the `veb.Context`.
@@ -96,20 +76,11 @@ fn parallel_request_handler[A, X](req fasthttp.HttpRequest) ![]u8 {
9676

9777
// runs middleware, and finds the correct route for a request.
9878
fn handle_request_and_route[A, X](mut app A, req http.Request, client_fd int, routes &map[string]Route, controllers []&ControllerPath) &Context {
99-
/*
100-
// Create a `net.TcpConn` from the file descriptor for context compatibility.
101-
mut conn := &net.TcpConn{
102-
sock: net.tcp_socket_from_handle_raw(client_fd)
103-
handle: client_fd
104-
is_blocking: false // vanilla_http_server ensures this
105-
}
106-
*/
10779
// Create and populate the `veb.Context` from the request.
10880
mut url := urllib.parse(req.url) or {
10981
// This should be rare if http.parse_request succeeded.
11082
mut bad_ctx := &Context{
11183
req: req
112-
// conn: conn
11384
}
11485
bad_ctx.not_found()
11586
return bad_ctx
@@ -118,7 +89,6 @@ fn handle_request_and_route[A, X](mut app A, req http.Request, client_fd int, ro
11889
form, files := parse_form_from_request(req) or {
11990
mut bad_ctx := &Context{
12091
req: req
121-
// conn: conn
12292
}
12393
bad_ctx.request_error('Failed to parse form data: ${err.msg()}')
12494
return bad_ctx
@@ -128,10 +98,9 @@ fn handle_request_and_route[A, X](mut app A, req http.Request, client_fd int, ro
12898
mut ctx := &Context{
12999
req: req
130100
page_gen_start: time.ticks()
131-
// conn: conn
132-
query: query
133-
form: form
134-
files: files
101+
query: query
102+
form: form
103+
files: files
135104
}
136105
if connection_header := req.header.get(.connection) {
137106
if connection_header.to_lower() == 'close' {
@@ -150,7 +119,6 @@ fn handle_request_and_route[A, X](mut app A, req http.Request, client_fd int, ro
150119
// Create a new user context and pass veb's context
151120
mut user_context := X{}
152121
user_context.Context = ctx
153-
// println('calling handle_route')
154122
handle_route[A, X](mut app, mut user_context, url, host, routes)
155123
return &user_context.Context
156124
}

0 commit comments

Comments
 (0)