Register parameter also for child classes overriding addHeaderPassthroughOption

This commit is contained in:
juan.marchionatto 2021-07-06 14:37:12 -04:00
parent 5c5bd1ec6c
commit 41e1b4d45c
1 changed files with 18 additions and 2 deletions

View File

@ -69,14 +69,30 @@ public abstract class BaseRequestGeneratingCommand extends BaseCommand {
@Override @Override
protected IGenericClient newClient(CommandLine theCommandLine) throws ParseException { protected IGenericClient newClient(CommandLine theCommandLine) throws ParseException {
IGenericClient client = super.newClient(theCommandLine); IGenericClient client = super.newClient(theCommandLine);
registerHeaderPassthrough(theCommandLine, client);
return client;
}
@Override
protected IGenericClient newClientWithBaseUrl(CommandLine theCommandLine, String theBaseUrl,
String theBasicAuthOptionName, String theBearerTokenOptionName) throws ParseException {
IGenericClient client = super.newClientWithBaseUrl(
theCommandLine, theBaseUrl, theBasicAuthOptionName, theBearerTokenOptionName);
registerHeaderPassthrough(theCommandLine, client);
return client;
}
private void registerHeaderPassthrough(CommandLine theCommandLine, IGenericClient theClient) throws ParseException {
if (theCommandLine.hasOption(HEADER_PASSTHROUGH)) { if (theCommandLine.hasOption(HEADER_PASSTHROUGH)) {
client.registerInterceptor( theClient.registerInterceptor(
new AdditionalRequestHeadersInterceptor( new AdditionalRequestHeadersInterceptor(
getAndParseOptionHeadersPassthrough(theCommandLine, HEADER_PASSTHROUGH))); getAndParseOptionHeadersPassthrough(theCommandLine, HEADER_PASSTHROUGH)));
} }
return client;
} }
private void addHeaderPassthroughOption(Options theOptions) { private void addHeaderPassthroughOption(Options theOptions) {