diff options
author | Martin Ashby <martin@ashbysoft.com> | 2023-08-06 19:55:20 +0100 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2023-08-06 19:55:20 +0100 |
commit | 8156e741ef7c8a59317ba801aa0c8940e9fcbd00 (patch) | |
tree | f18649c32ced71308a0fc5b0ff231c41f28b8bea /src/main.zig | |
parent | 95699a6ed77e1480e7b9256035225981cb33bfbb (diff) | |
download | zigwebserver-8156e741ef7c8a59317ba801aa0c8940e9fcbd00.tar.gz zigwebserver-8156e741ef7c8a59317ba801aa0c8940e9fcbd00.tar.bz2 zigwebserver-8156e741ef7c8a59317ba801aa0c8940e9fcbd00.tar.xz zigwebserver-8156e741ef7c8a59317ba801aa0c8940e9fcbd00.zip |
Percent-decode query parameters like they shoud be according to the spec
https://www.w3.org/TR/html401/interact/forms.html
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig index 1f4d8f9..70869b2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -10,7 +10,8 @@ const Context = struct { }; const Handler = struct { pub fn handle(_: Handler, res: *std.http.Server.Response, _: Context) !void { - const p = try zws.Path.parse(res.request.target); + var p = try zws.Path.parse(res.allocator, res.request.target); + defer p.deinit(); const path = try std.fs.path.join(res.allocator, &[_][]const u8{ ".", p.path }); defer res.allocator.free(path); if (std.fs.cwd().openFile(path, .{})) |file| { @@ -43,7 +44,7 @@ const Handler = struct { while (true) { const read = try file.read(&buf); if (read == 0) break; - _ = try res.write(buf[0..read]); + _ = try res.writeAll(buf[0..read]); } } |