Skip to content

Commit

Permalink
net.http: fix http.delete() checking (#20131)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 10, 2023
1 parent fe4e1c0 commit 42a8c7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vlib/net/http/header.v
Expand Up @@ -469,8 +469,8 @@ pub fn (mut h Header) delete(key CommonHeader) {

// delete_custom deletes all values for a custom header key.
pub fn (mut h Header) delete_custom(key string) {
for i, kv in h.data {
if kv.key == key {
for i := 0; i < h.cur_pos; i++ {
if h.data[i].key == key {
h.data[i] = HeaderKV{key, ''}
}
}
Expand Down
7 changes: 7 additions & 0 deletions vlib/net/http/header_test.v
Expand Up @@ -79,6 +79,13 @@ fn test_header_delete_not_existing() {
// assert h.keys.len == 0
}

fn test_delete_header() {
mut r := new_request(.get, '', '')
r.header.set(.authorization, 'foo')
r.header.delete(.authorization)
assert r.header.get(.authorization)! == ''
}

fn test_custom_header() {
mut h := new_header()
h.add_custom('AbC', 'dEf')!
Expand Down

0 comments on commit 42a8c7e

Please sign in to comment.