mirror of
https://github.com/mirror/wget.git
synced 2024-12-28 22:00:27 +08:00
4ce2f93600
of the header field while RejectHeader rejects ONLY the specified full header. Since we wanted to be sure a header field is not sent to the server we wrote this rule. * doc/wget.texi: Added --disable-header documentation. * fuzz/wget_options_fuzzer.dict: Update with --disable-header inputs. * src/http.c (disabled_header): Checks for disabled headers (request_set_header): Doesn't let header to be set if disabled (gethttp): frees disabled header to let overriding * src/init.c (cmd_dis_header), (check_user_disabled_header) added new option disabled_headers. * src/main.c: added new option --disable-header, added help description * src/options.h: added new option --disable-header * src/utils.h (vec_remove_header) * src/utils.c (vec_remove_header) removes all header instances from vector * testenv/Makefile.am: Added new test files * testenv/server/http/http_server.py: Added new rule RejectHeaderField * testenv/conf/reject_header_field.py: Added new rule RejectHeaderField * testenv/README: Added help description for new rule * testenv/Test-disable-default-headers.py: Test without using --header * testenv/Test-disable-headers-after.py: Test using --header before --disable-header * testenv/Test-disable-headers-before.py: Test using --header after --disable-header Signed-off-by: sulfastor <torresmoisesa@gmail.com>, adham elkarn <adhamelkarn@hotmail.com>
79 lines
1.9 KiB
Python
79 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
from sys import exit
|
|
from test.http_test import HTTPTest
|
|
from test.base_test import HTTP, HTTPS
|
|
from misc.wget_file import WgetFile
|
|
|
|
"""
|
|
This is test ensures that the --disable-header option doesn't remove user headers
|
|
from the HTTP request when it's placed before --header="header: value".
|
|
"""
|
|
############# File Definitions ###############################################
|
|
file_content = """Les paroles de la bouche d'un homme sont des eaux profondes;
|
|
La source de la sagesse est un torrent qui jaillit."""
|
|
|
|
Headers = {
|
|
'Authorization',
|
|
'User-Agent',
|
|
'Referer',
|
|
'Cache-Control',
|
|
'Pragma',
|
|
'If-Modified-Since',
|
|
'Range',
|
|
'Accept',
|
|
'Accept-Encoding',
|
|
'Host',
|
|
'Connection',
|
|
'Proxy-Connection',
|
|
'Content-Type',
|
|
'Content-Length',
|
|
'Proxy-Authorization',
|
|
'Cookie',
|
|
'MyHeader',
|
|
}
|
|
|
|
WGET_OPTIONS = '--disable-header="'
|
|
WGET_URLS = [[]]
|
|
Files = [[]]
|
|
headers_len = len(Headers)
|
|
|
|
for index, header in enumerate(Headers, start=1):
|
|
File_rules = {
|
|
"ExpectHeader" : {
|
|
header : 'any'
|
|
}
|
|
}
|
|
file_name = "File" + str(index)
|
|
Files[0].append (WgetFile(file_name, file_content, rules=File_rules))
|
|
WGET_OPTIONS += header + (',' if index < headers_len else '"')
|
|
WGET_URLS[0].append (file_name)
|
|
|
|
# Define user defined headers
|
|
for header in Headers:
|
|
WGET_OPTIONS += ' --header="' + header + ': any"'
|
|
|
|
Servers = [HTTP]
|
|
|
|
ExpectedReturnCode = 0
|
|
|
|
################ Pre and Post Test Hooks #####################################
|
|
pre_test = {
|
|
"ServerFiles" : Files
|
|
}
|
|
test_options = {
|
|
"WgetCommands" : WGET_OPTIONS,
|
|
"Urls" : WGET_URLS
|
|
}
|
|
post_test = {
|
|
"ExpectedRetcode" : ExpectedReturnCode
|
|
}
|
|
|
|
err = HTTPTest (
|
|
pre_hook=pre_test,
|
|
test_params=test_options,
|
|
post_hook=post_test,
|
|
protocols=Servers
|
|
).begin ()
|
|
|
|
exit (err)
|