Skip to content

Commit

Permalink
- Add new parameter disableCompression to log http payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Aug 9, 2022
1 parent 082cc9d commit 254fdc6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- oas 3.0 base path handling (See issue [#297](https://github.com/Axway-API-Management-Plus/apim-cli/issues/297)
- BackendBasepath problem exporting SOAP API with apim-cli (See issue [#299](https://github.com/Axway-API-Management-Plus/apim-cli/issues/299)
- Importing SOAP API with apim-cli adds "+" instead of spaces for the Backend API name (See issue [#301](https://github.com/Axway-API-Management-Plus/apim-cli/issues/301)

### Changed
- Added new parameter disableCompression. The parameter enables logging API Gateway responses for debugging.
- Usage - **api get -u apiadmin -p Space*Salt*25 -h 208.67.129.25 -port 8075 -n "PetStore 3.0" -o json -disableCompression**
- Enable http client header and payload logging using jvm -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG
- If backendBasepath is present in api-config.json, Openapi (OAS 3) servers.url will be modified based on the values. E.g
- If open api servers.url is /api/v3 and backendBasepath is https://backend, the openapi server.url will be replaced with https://backend/api/v3
- If open api servers.url is https://petstore.swagger.io/api/v3 and backendBasepath is https://backend, the openapi server.url will be replaced with https://backend/api/v3
- If open api servers.url is https://petstore.swagger.io/api/v3 and backendBasepath is https://backend/api, the openapi server.url will be replaced with https://backend/api/api/v3


## [1.12.2] 2022-07-28

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ public Parameters getParams() throws AppException {
params.setProxyUsername(getValue("httpProxyUsername"));
params.setProxyPassword(getValue("httpProxyPassword"));
params.setRetryDelay(getValue("retryDelay"));


return (Parameters) params;
params.setDisableCompression(hasOption("disableCompression"));
return params;
}

@Override
Expand Down Expand Up @@ -159,6 +158,10 @@ public void addOptions() {
option.setRequired(false);
option.setArgName("true");
cliOptions.addInternalOption(option);

option = new Option("disableCompression", false, "Disable Http Client gzip Compression");
option.setRequired(false);
cliOptions.addInternalOption(option);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static Mode valueOfDefault(String key) {
private String proxyPassword;

private int retryDelay;

private boolean disableCompression;

public CoreParameters() {
super();
Expand Down Expand Up @@ -544,6 +546,14 @@ public List<CacheType> getEnabledCacheTypes() {
return null;
}

public boolean isDisableCompression() {
return disableCompression;
}

public void setDisableCompression(boolean disableCompression) {
this.disableCompression = disableCompression;
}

@Override
public String toString() {
return "[hostname=" + hostname + ", username=" + username + ", stage=" + stage + "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ private void createConnection(URI uri) throws AppException {
}
defaultRequestConfig.setProxy(proxyHost);
}
if(params.isDisableCompression())
clientBuilder.disableContentCompression();
clientBuilder.setDefaultRequestConfig(defaultRequestConfig.build());
this.httpClient = clientBuilder.build();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,21 @@ public void testAPIBasePathParam() throws ParseException, AppException {

Assert.assertEquals(params.getApiBasepath(), "/fr/apim/v13/portal");
}

@Test
public void testDisableCompression() throws AppException {
String[] args = {"-disableCompression"};
CLIOptions options = SampleCLIOptions.create(args);
CoreParameters params = (CoreParameters) options.getParams();
Assert.assertEquals(params.isDisableCompression(), true);

}
@Test
public void testDisableCompressionNegative() throws AppException {
String[] args = {""};
CLIOptions options = SampleCLIOptions.create(args);
CoreParameters params = (CoreParameters) options.getParams();
Assert.assertEquals(params.isDisableCompression(), false);

}
}

0 comments on commit 254fdc6

Please sign in to comment.