mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 14:06:08 +00:00
Merge pull request #102 from jetzig-framework/http.zig-vuln-patch
Update http.zig
This commit is contained in:
commit
852129384b
@ -23,8 +23,8 @@
|
|||||||
.hash = "1220cebfcf6c63295819df92ec54abe62aad91b1d16666781194c29a7874bb7bbbda",
|
.hash = "1220cebfcf6c63295819df92ec54abe62aad91b1d16666781194c29a7874bb7bbbda",
|
||||||
},
|
},
|
||||||
.httpz = .{
|
.httpz = .{
|
||||||
.url = "https://github.com/karlseguin/http.zig/archive/30195d6e668d1cb97630bab282d4ac7f147af607.tar.gz",
|
.url = "https://github.com/karlseguin/http.zig/archive/da9e944de0be6e5c67ca711dd238ce82d81558b4.tar.gz",
|
||||||
.hash = "12204f7c5a6b8a6988ab7cbccaf3c1c6199fbf423741412a607be8bde835fb4b8cc8",
|
.hash = "12201df692f62d526fdf94e6000cf8de2142edf27484887e2e8f1ec5db4c9b808e5c",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -5,14 +5,14 @@ const httpz = @import("httpz");
|
|||||||
const jetzig = @import("../../jetzig.zig");
|
const jetzig = @import("../../jetzig.zig");
|
||||||
|
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
httpz_headers: *httpz.key_value.KeyValue,
|
httpz_headers: *httpz.key_value.StringKeyValue,
|
||||||
new_headers: std.ArrayList(Header),
|
new_headers: std.ArrayList(Header),
|
||||||
|
|
||||||
const Headers = @This();
|
const Headers = @This();
|
||||||
const Header = struct { name: []const u8, value: []const u8 };
|
const Header = struct { name: []const u8, value: []const u8 };
|
||||||
const max_bytes_header_name = jetzig.config.get(u8, "max_bytes_header_name");
|
const max_bytes_header_name = jetzig.config.get(u8, "max_bytes_header_name");
|
||||||
|
|
||||||
pub fn init(allocator: std.mem.Allocator, httpz_headers: *httpz.key_value.KeyValue) Headers {
|
pub fn init(allocator: std.mem.Allocator, httpz_headers: *httpz.key_value.StringKeyValue) Headers {
|
||||||
return .{
|
return .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.httpz_headers = httpz_headers,
|
.httpz_headers = httpz_headers,
|
||||||
@ -121,7 +121,7 @@ pub fn iterator(self: Headers) Iterator {
|
|||||||
|
|
||||||
test "append (deprecated)" {
|
test "append (deprecated)" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
var httpz_headers = try httpz.key_value.KeyValue.init(allocator, 10);
|
var httpz_headers = try httpz.key_value.StringKeyValue.init(allocator, 10);
|
||||||
var headers = Headers.init(allocator, &httpz_headers);
|
var headers = Headers.init(allocator, &httpz_headers);
|
||||||
defer headers.deinit();
|
defer headers.deinit();
|
||||||
try headers.append("foo", "bar");
|
try headers.append("foo", "bar");
|
||||||
@ -130,7 +130,7 @@ test "append (deprecated)" {
|
|||||||
|
|
||||||
test "add" {
|
test "add" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
var httpz_headers = try httpz.key_value.KeyValue.init(allocator, 10);
|
var httpz_headers = try httpz.key_value.StringKeyValue.init(allocator, 10);
|
||||||
var headers = Headers.init(allocator, &httpz_headers);
|
var headers = Headers.init(allocator, &httpz_headers);
|
||||||
defer headers.deinit();
|
defer headers.deinit();
|
||||||
try headers.append("foo", "bar");
|
try headers.append("foo", "bar");
|
||||||
@ -139,7 +139,7 @@ test "add" {
|
|||||||
|
|
||||||
test "get with multiple headers (bugfix regression test)" {
|
test "get with multiple headers (bugfix regression test)" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
var httpz_headers = try httpz.key_value.KeyValue.init(allocator, 10);
|
var httpz_headers = try httpz.key_value.StringKeyValue.init(allocator, 10);
|
||||||
var headers = Headers.init(allocator, &httpz_headers);
|
var headers = Headers.init(allocator, &httpz_headers);
|
||||||
defer headers.deinit();
|
defer headers.deinit();
|
||||||
try headers.append("foo", "bar");
|
try headers.append("foo", "bar");
|
||||||
@ -149,7 +149,7 @@ test "get with multiple headers (bugfix regression test)" {
|
|||||||
|
|
||||||
test "getAll" {
|
test "getAll" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
var httpz_headers = try httpz.key_value.KeyValue.init(allocator, 10);
|
var httpz_headers = try httpz.key_value.StringKeyValue.init(allocator, 10);
|
||||||
var headers = Headers.init(allocator, &httpz_headers);
|
var headers = Headers.init(allocator, &httpz_headers);
|
||||||
defer headers.deinit();
|
defer headers.deinit();
|
||||||
try headers.append("foo", "bar");
|
try headers.append("foo", "bar");
|
||||||
@ -162,7 +162,7 @@ test "getAll" {
|
|||||||
|
|
||||||
test "add too many headers" {
|
test "add too many headers" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
var httpz_headers = try httpz.key_value.KeyValue.init(allocator, 10);
|
var httpz_headers = try httpz.key_value.StringKeyValue.init(allocator, 10);
|
||||||
var headers = Headers.init(allocator, &httpz_headers);
|
var headers = Headers.init(allocator, &httpz_headers);
|
||||||
defer headers.deinit();
|
defer headers.deinit();
|
||||||
for (0..10) |_| try headers.append("foo", "bar");
|
for (0..10) |_| try headers.append("foo", "bar");
|
||||||
@ -172,7 +172,7 @@ test "add too many headers" {
|
|||||||
|
|
||||||
test "case-insensitive matching" {
|
test "case-insensitive matching" {
|
||||||
const allocator = std.testing.allocator;
|
const allocator = std.testing.allocator;
|
||||||
var httpz_headers = try httpz.key_value.KeyValue.init(allocator, 10);
|
var httpz_headers = try httpz.key_value.StringKeyValue.init(allocator, 10);
|
||||||
var headers = Headers.init(allocator, &httpz_headers);
|
var headers = Headers.init(allocator, &httpz_headers);
|
||||||
defer headers.deinit();
|
defer headers.deinit();
|
||||||
try headers.append("Content-Type", "bar");
|
try headers.append("Content-Type", "bar");
|
||||||
|
@ -5,7 +5,7 @@ const httpz = @import("httpz");
|
|||||||
const jetzig = @import("../../jetzig.zig");
|
const jetzig = @import("../../jetzig.zig");
|
||||||
|
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
key_value: httpz.key_value.MultiFormKeyValue,
|
key_value: *httpz.key_value.MultiFormKeyValue,
|
||||||
|
|
||||||
const MultipartQuery = @This();
|
const MultipartQuery = @This();
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ pub fn init(
|
|||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.path = jetzig.http.Path.init(httpz_request.url.raw),
|
.path = jetzig.http.Path.init(httpz_request.url.raw),
|
||||||
.method = method,
|
.method = method,
|
||||||
.headers = jetzig.http.Headers.init(allocator, &httpz_request.headers),
|
.headers = jetzig.http.Headers.init(allocator, httpz_request.headers),
|
||||||
.server = server,
|
.server = server,
|
||||||
.response = response,
|
.response = response,
|
||||||
.response_data = response_data,
|
.response_data = response_data,
|
||||||
|
@ -264,7 +264,7 @@ fn stubbedResponse(allocator: std.mem.Allocator) !httpz.Response {
|
|||||||
.conn = undefined,
|
.conn = undefined,
|
||||||
.pos = 0,
|
.pos = 0,
|
||||||
.status = 200,
|
.status = 200,
|
||||||
.headers = try keyValue(allocator, 32),
|
.headers = (try keyValue(allocator, 32)).*,
|
||||||
.content_type = null,
|
.content_type = null,
|
||||||
.arena = allocator,
|
.arena = allocator,
|
||||||
.written = false,
|
.written = false,
|
||||||
@ -275,12 +275,16 @@ fn stubbedResponse(allocator: std.mem.Allocator) !httpz.Response {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keyValue(allocator: std.mem.Allocator, max: usize) !httpz.key_value.KeyValue {
|
fn keyValue(allocator: std.mem.Allocator, max: usize) !*httpz.key_value.StringKeyValue {
|
||||||
return try httpz.key_value.KeyValue.init(allocator, max);
|
const key_value = try allocator.create(httpz.key_value.StringKeyValue);
|
||||||
|
key_value.* = try httpz.key_value.StringKeyValue.init(allocator, max);
|
||||||
|
return key_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn multiFormKeyValue(allocator: std.mem.Allocator, max: usize) !httpz.key_value.MultiFormKeyValue {
|
fn multiFormKeyValue(allocator: std.mem.Allocator, max: usize) !*httpz.key_value.MultiFormKeyValue {
|
||||||
return try httpz.key_value.MultiFormKeyValue.init(allocator, max);
|
const key_value = try allocator.create(httpz.key_value.MultiFormKeyValue);
|
||||||
|
key_value.* = try httpz.key_value.MultiFormKeyValue.init(allocator, max);
|
||||||
|
return key_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createStore(allocator: std.mem.Allocator) !*jetzig.kv.Store {
|
fn createStore(allocator: std.mem.Allocator) !*jetzig.kv.Store {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user