+ pub fn get_header(self: Request, name: []const u8) ?[]const u8 {
+ const head = self.head orelse return null;
+ const header_start = std.mem.indexOf(u8, head, name) orelse return null;
+ const colon_index = std.mem.indexOfPos(u8, head, header_start, ": ") orelse return null;
+ const header_end = std.mem.indexOfPos(u8, head, colon_index, "\r\n") orelse return null;
+ return head[colon_index + 2 .. header_end];
+ }
+
+ pub fn get_param(self: Request, name: []const u8) ?[]const u8 {
+ const query = self.query orelse return null;
+ const name_index = std.mem.indexOf(u8, query, name) orelse return null;
+ const eql_index = std.mem.indexOfScalarPos(u8, query, name_index, '=') orelse return null;
+ if (std.mem.indexOfScalarPos(u8, query, name_index, '&')) |amp_index| {
+ const result = query[eql_index + 1 .. amp_index];
+ return result;
+ } else {
+ const result = query[eql_index + 1 .. query.len];
+ return result;
+ }
+ }
+
+ pub fn get_value(self: Request, name: []const u8) ?[]const u8 {
+ const body = self.body orelse return null;
+ const name_index = std.mem.indexOf(u8, body, name) orelse return null;
+ const eql_index = std.mem.indexOfScalarPos(u8, body, name_index, '=') orelse return null;
+ if (std.mem.indexOfScalarPos(u8, body, name_index, '&')) |amp_index| {
+ const result = body[eql_index + 1 .. amp_index];
+ return result;
+ } else {
+ const result = body[eql_index + 1 .. body.len];
+ return result;
+ }
+ }
+
+ pub fn get_cookie1(self: Request, name: []const u8) ?[]const u8 {