Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion response.odin
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ _response_write_heading :: proc(r: ^Response, content_length: int) {
ws(b, "\r\n")

// Per RFC 9910 6.6.1 a Date header must be added in 2xx, 3xx, 4xx responses.
if r.status >= .OK && r.status <= .Internal_Server_Error && !headers_has_unsafe(r.headers, "date") {
if td.state != .Testing && r.status >= .OK && r.status <= .Internal_Server_Error && !headers_has_unsafe(r.headers, "date") {
ws(b, "date: ")
ws(b, server_date(conn.server))
ws(b, "\r\n")
Expand Down
7 changes: 6 additions & 1 deletion responses.odin
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ If any other error occurs, a 500 is sent and the error is logged.
*/
respond_file :: proc(r: ^Response, path: string, content_type: Maybe(Mime_Type) = nil, loc := #caller_location) {
// PERF: we are still putting the content into the body buffer, we could stream it.

if td.state == .Testing {
return
}
assert_has_td(loc)
assert(!r.sent, "response has already been sent", loc)

Expand Down Expand Up @@ -168,6 +170,9 @@ respond_json :: proc(r: ^Response, v: any, status: Status = .OK, opt: json.Marsh
Prefer the procedure group `respond`.
*/
respond_with_none :: proc(r: ^Response, loc := #caller_location) {
if td.state == .Testing {
return
}
assert_has_td(loc)

conn := r._conn
Expand Down
1 change: 1 addition & 0 deletions server.odin
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Server_State :: enum {
Closing,
Cleaning,
Closed,
Testing,
}

Server :: struct {
Expand Down