mirror of
https://github.com/vlang/v.git
synced 2025-09-09 23:39:39 -04:00
net.http: fix http.delete() checking (#20131)
This commit is contained in:
parent
fe4e1c0672
commit
42a8c7e16b
@ -469,8 +469,8 @@ pub fn (mut h Header) delete(key CommonHeader) {
|
|||||||
|
|
||||||
// delete_custom deletes all values for a custom header key.
|
// delete_custom deletes all values for a custom header key.
|
||||||
pub fn (mut h Header) delete_custom(key string) {
|
pub fn (mut h Header) delete_custom(key string) {
|
||||||
for i, kv in h.data {
|
for i := 0; i < h.cur_pos; i++ {
|
||||||
if kv.key == key {
|
if h.data[i].key == key {
|
||||||
h.data[i] = HeaderKV{key, ''}
|
h.data[i] = HeaderKV{key, ''}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,13 @@ fn test_header_delete_not_existing() {
|
|||||||
// assert h.keys.len == 0
|
// 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() {
|
fn test_custom_header() {
|
||||||
mut h := new_header()
|
mut h := new_header()
|
||||||
h.add_custom('AbC', 'dEf')!
|
h.add_custom('AbC', 'dEf')!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user