[params] Allow for arbitrary HTTP request headers to be specified

Extend the request parameter mechanism to allow for arbitrary HTTP
headers to be specified via e.g.:

  params
  param --header Referer http://www.example.com
  imgfetch http://192.168.0.1/script.ipxe##params

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2023-02-28 17:46:13 +00:00
parent 33cb56cf1b
commit 96bb6ba441
5 changed files with 73 additions and 15 deletions

View File

@@ -98,6 +98,8 @@ struct uri_params_test_list {
const char *key;
/** Value */
const char *value;
/** Flags */
unsigned int flags;
};
/** A request parameter URI test */
@@ -428,6 +430,7 @@ static void uri_params_list_okx ( struct uri_params_test *test,
file, line );
okx ( strcmp ( param->value, list->value ) == 0,
file, line );
okx ( param->flags == list->flags, file, line );
list++;
}
okx ( list->key == NULL, file, line );
@@ -456,7 +459,8 @@ static void uri_params_okx ( struct uri_params_test *test, const char *file,
okx ( params != NULL, file, line );
if ( params ) {
for ( list = test->list ; list->key ; list++ ) {
param = add_parameter ( params, list->key, list->value);
param = add_parameter ( params, list->key, list->value,
list->flags );
okx ( param != NULL, file, line );
}
}
@@ -884,18 +888,22 @@ static struct uri_params_test_list uri_params_list[] = {
{
"vendor",
"10ec",
PARAMETER_FORM,
},
{
"device",
"8139",
PARAMETER_FORM,
},
{
"uuid",
"f59fac00-758f-498f-9fe5-87d790045d94",
PARAMETER_HEADER,
},
{
NULL,
NULL,
0,
}
};
@@ -917,14 +925,17 @@ static struct uri_params_test_list uri_named_params_list[] = {
{
"mac",
"00:1e:65:80:d3:b6",
PARAMETER_FORM,
},
{
"serial",
"LXTQ20Z1139322762F2000",
PARAMETER_FORM,
},
{
NULL,
NULL,
0,
}
};