Skip to content

Commit

Permalink
fix(response) use charset from response header when parsing body (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbioteau authored Nov 18, 2020
1 parent 01c3e38 commit 6931d46
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,44 @@

public abstract class AbstractRESTConnectorImpl extends AbstractConnector {

protected final static String URL_INPUT_PARAMETER = "url";
protected final static String METHOD_INPUT_PARAMETER = "method";
protected final static String CONTENTTYPE_INPUT_PARAMETER = "contentType";
protected final static String CHARSET_INPUT_PARAMETER = "charset";
protected final static String URLCOOKIES_INPUT_PARAMETER = "urlCookies";
protected final static String URLHEADERS_INPUT_PARAMETER = "urlHeaders";
protected final static String BODY_INPUT_PARAMETER = "body";
protected final static String DO_NOT_FOLLOW_REDIRECT_INPUT_PARAMETER = "do_not_follow_redirect";
protected final static String IGNORE_BODY_INPUT_PARAMETER = "ignore_body";
protected final static String TRUST_SELF_SIGNED_CERTIFICATE_INPUT_PARAMETER = "trust_self_signed_certificate";
protected final static String TLS_INPUT_PARAMETER = "TLS";
protected final static String HOSTNAME_VERIFIER_INPUT_PARAMETER = "hostname_verifier";
protected final static String TRUST_STORE_FILE_INPUT_PARAMETER = "trust_store_file";
protected final static String TRUST_STORE_PASSWORD_INPUT_PARAMETER = "trust_store_password";
protected final static String KEY_STORE_FILE_INPUT_PARAMETER = "key_store_file";
protected final static String KEY_STORE_PASSWORD_INPUT_PARAMETER = "key_store_password";
protected final static String AUTH_TYPE_PARAMETER = "auth_type";
protected final static String AUTH_USERNAME_INPUT_PARAMETER = "auth_username";
protected final static String AUTH_PASSWORD_INPUT_PARAMETER = "auth_password";
protected final static String AUTH_HOST_INPUT_PARAMETER = "auth_host";
protected final static String AUTH_PORT_INPUT_PARAMETER = "auth_port";
protected final static String AUTH_REALM_INPUT_PARAMETER = "auth_realm";
protected final static String AUTH_PREEMPTIVE_INPUT_PARAMETER = "auth_preemptive";
protected final static String PROXY_PROTOCOL_INPUT_PARAMETER = "proxy_protocol";
protected final static String PROXY_HOST_INPUT_PARAMETER = "proxy_host";
protected final static String PROXY_PORT_INPUT_PARAMETER = "proxy_port";
protected final static String PROXY_USERNAME_INPUT_PARAMETER = "proxy_username";
protected final static String PROXY_PASSWORD_INPUT_PARAMETER = "proxy_password";
protected final static String BODY_AS_STRING_OUTPUT_PARAMETER = "bodyAsString";
protected final static String BODY_AS_OBJECT_OUTPUT_PARAMETER = "bodyAsObject";
protected final static String HEADERS_OUTPUT_PARAMETER = "headers";
protected final static String STATUS_CODE_OUTPUT_PARAMETER = "status_code";
protected final static String STATUS_MESSAGE_OUTPUT_PARAMETER = "status_message";
protected final static String SOCKET_TIMEOUT_MS_PARAMETER = "socket_timeout_ms";
protected final static String CONNECTION_TIMEOUT_MS_PARAMETER = "connection_timeout_ms";

protected final static int SOCKET_TIMEOUT_MS_DEFAULT_VALUE = 60_000;
protected final static int CONNECTION_TIMEOUT_MS_DEFAULT_VALUE = 60_000;
protected static final String URL_INPUT_PARAMETER = "url";
protected static final String METHOD_INPUT_PARAMETER = "method";
protected static final String CONTENTTYPE_INPUT_PARAMETER = "contentType";
protected static final String CHARSET_INPUT_PARAMETER = "charset";
protected static final String URLCOOKIES_INPUT_PARAMETER = "urlCookies";
protected static final String URLHEADERS_INPUT_PARAMETER = "urlHeaders";
protected static final String BODY_INPUT_PARAMETER = "body";
protected static final String DO_NOT_FOLLOW_REDIRECT_INPUT_PARAMETER = "do_not_follow_redirect";
protected static final String IGNORE_BODY_INPUT_PARAMETER = "ignore_body";
protected static final String TRUST_SELF_SIGNED_CERTIFICATE_INPUT_PARAMETER = "trust_self_signed_certificate";
protected static final String TLS_INPUT_PARAMETER = "TLS";
protected static final String HOSTNAME_VERIFIER_INPUT_PARAMETER = "hostname_verifier";
protected static final String TRUST_STORE_FILE_INPUT_PARAMETER = "trust_store_file";
protected static final String TRUST_STORE_PASSWORD_INPUT_PARAMETER = "trust_store_password";
protected static final String KEY_STORE_FILE_INPUT_PARAMETER = "key_store_file";
protected static final String KEY_STORE_PASSWORD_INPUT_PARAMETER = "key_store_password";
protected static final String AUTH_TYPE_PARAMETER = "auth_type";
protected static final String AUTH_USERNAME_INPUT_PARAMETER = "auth_username";
protected static final String AUTH_PASSWORD_INPUT_PARAMETER = "auth_password";
protected static final String AUTH_HOST_INPUT_PARAMETER = "auth_host";
protected static final String AUTH_PORT_INPUT_PARAMETER = "auth_port";
protected static final String AUTH_REALM_INPUT_PARAMETER = "auth_realm";
protected static final String AUTH_PREEMPTIVE_INPUT_PARAMETER = "auth_preemptive";
protected static final String PROXY_PROTOCOL_INPUT_PARAMETER = "proxy_protocol";
protected static final String PROXY_HOST_INPUT_PARAMETER = "proxy_host";
protected static final String PROXY_PORT_INPUT_PARAMETER = "proxy_port";
protected static final String PROXY_USERNAME_INPUT_PARAMETER = "proxy_username";
protected static final String PROXY_PASSWORD_INPUT_PARAMETER = "proxy_password";
protected static final String BODY_AS_STRING_OUTPUT_PARAMETER = "bodyAsString";
protected static final String BODY_AS_OBJECT_OUTPUT_PARAMETER = "bodyAsObject";
protected static final String HEADERS_OUTPUT_PARAMETER = "headers";
protected static final String STATUS_CODE_OUTPUT_PARAMETER = "status_code";
protected static final String STATUS_MESSAGE_OUTPUT_PARAMETER = "status_message";
protected static final String SOCKET_TIMEOUT_MS_PARAMETER = "socket_timeout_ms";
protected static final String CONNECTION_TIMEOUT_MS_PARAMETER = "connection_timeout_ms";

protected static final int SOCKET_TIMEOUT_MS_DEFAULT_VALUE = 60_000;
protected static final int CONNECTION_TIMEOUT_MS_DEFAULT_VALUE = 60_000;

protected final java.lang.String getUrl() {
return (java.lang.String) getInputParameter(URL_INPUT_PARAMETER);
Expand All @@ -80,8 +80,8 @@ protected final java.lang.String getCharset() {
return (java.lang.String) getInputParameter(CHARSET_INPUT_PARAMETER);
}

protected final java.util.List getUrlCookies() {
java.util.List cookies = (java.util.List) getInputParameter(URLCOOKIES_INPUT_PARAMETER);
protected final List getUrlCookies() {
List cookies = (List) getInputParameter(URLCOOKIES_INPUT_PARAMETER);
if (cookies == null) {
cookies = Collections.emptyList();
}
Expand All @@ -108,109 +108,109 @@ private boolean emptyCell(final List line, int cellIndex) {
};
}

protected final java.util.List getUrlHeaders() {
java.util.List headers = (java.util.List) getInputParameter(URLHEADERS_INPUT_PARAMETER);
protected final List getUrlHeaders() {
List headers = (List) getInputParameter(URLHEADERS_INPUT_PARAMETER);
if (headers == null) {
headers = Collections.emptyList();
}
headers.removeIf(emptyLines());
return headers;
}

protected final java.lang.String getBody() {
return (java.lang.String) getInputParameter(BODY_INPUT_PARAMETER);
protected final String getBody() {
return (String) getInputParameter(BODY_INPUT_PARAMETER);
}

protected final java.lang.Boolean getTLS() {
final java.lang.Boolean tlsParam = (java.lang.Boolean) getInputParameter(TLS_INPUT_PARAMETER);
protected final Boolean getTLS() {
final Boolean tlsParam = (Boolean) getInputParameter(TLS_INPUT_PARAMETER);
return tlsParam != null ? tlsParam : Boolean.TRUE;
}

protected final java.lang.Boolean getTrust_self_signed_certificate() {
final java.lang.Boolean trustParam = (java.lang.Boolean) getInputParameter(
protected final Boolean getTrustSelfSignedCertificate() {
final Boolean trustParam = (Boolean) getInputParameter(
TRUST_SELF_SIGNED_CERTIFICATE_INPUT_PARAMETER);
return trustParam != null ? trustParam : Boolean.FALSE;
}

protected final java.lang.String getHostname_verifier() {
return (java.lang.String) getInputParameter(HOSTNAME_VERIFIER_INPUT_PARAMETER);
protected final String getHostnameVerifier() {
return (String) getInputParameter(HOSTNAME_VERIFIER_INPUT_PARAMETER);
}

protected final java.lang.String getTrust_store_file() {
return (java.lang.String) getInputParameter(TRUST_STORE_FILE_INPUT_PARAMETER);
protected final String getTrustStoreFile() {
return (String) getInputParameter(TRUST_STORE_FILE_INPUT_PARAMETER);
}

protected final java.lang.String getTrust_store_password() {
return (java.lang.String) getInputParameter(TRUST_STORE_PASSWORD_INPUT_PARAMETER);
protected final String getTrustStorePassword() {
return (String) getInputParameter(TRUST_STORE_PASSWORD_INPUT_PARAMETER);
}

protected final java.lang.String getKey_store_file() {
return (java.lang.String) getInputParameter(KEY_STORE_FILE_INPUT_PARAMETER);
protected final String getKeyStoreFile() {
return (String) getInputParameter(KEY_STORE_FILE_INPUT_PARAMETER);
}

protected final java.lang.String getKey_store_password() {
return (java.lang.String) getInputParameter(KEY_STORE_PASSWORD_INPUT_PARAMETER);
protected final String getKeyStorePassword() {
return (String) getInputParameter(KEY_STORE_PASSWORD_INPUT_PARAMETER);
}

protected final java.lang.Boolean getDoNotFollowRedirect() {
final java.lang.Boolean follozRedirect = (java.lang.Boolean) getInputParameter(
protected final Boolean getDoNotFollowRedirect() {
final Boolean follozRedirect = (Boolean) getInputParameter(
DO_NOT_FOLLOW_REDIRECT_INPUT_PARAMETER);
return follozRedirect != null ? follozRedirect : Boolean.FALSE;
}

protected final java.lang.Boolean getIgnoreBody() {
final java.lang.Boolean ignoreBody = (java.lang.Boolean) getInputParameter(IGNORE_BODY_INPUT_PARAMETER);
protected final Boolean getIgnoreBody() {
final Boolean ignoreBody = (Boolean) getInputParameter(IGNORE_BODY_INPUT_PARAMETER);
return ignoreBody != null ? ignoreBody : Boolean.FALSE;
}

protected final java.lang.String getAuth_username() {
return (java.lang.String) getInputParameter(AUTH_USERNAME_INPUT_PARAMETER);
protected final String getAuthUsername() {
return (String) getInputParameter(AUTH_USERNAME_INPUT_PARAMETER);
}

protected final java.lang.String getAuth_password() {
return (java.lang.String) getInputParameter(AUTH_PASSWORD_INPUT_PARAMETER);
protected final String getAuthPassword() {
return (String) getInputParameter(AUTH_PASSWORD_INPUT_PARAMETER);
}

protected final java.lang.String getAuth_host() {
return (java.lang.String) getInputParameter(AUTH_HOST_INPUT_PARAMETER);
protected final String getAuthHost() {
return (String) getInputParameter(AUTH_HOST_INPUT_PARAMETER);
}

protected final java.lang.Integer getAuth_port() {
return (java.lang.Integer) getInputParameter(AUTH_PORT_INPUT_PARAMETER);
protected final Integer getAuthPort() {
return (Integer) getInputParameter(AUTH_PORT_INPUT_PARAMETER);
}

protected final java.lang.String getAuth_realm() {
return (java.lang.String) getInputParameter(AUTH_REALM_INPUT_PARAMETER);
protected final String getAuthRealm() {
return (String) getInputParameter(AUTH_REALM_INPUT_PARAMETER);
}

protected final java.lang.Boolean getAuth_preemptive() {
final java.lang.Boolean preemptive = (java.lang.Boolean) getInputParameter(AUTH_PREEMPTIVE_INPUT_PARAMETER);
protected final Boolean getAuthPreemptive() {
final Boolean preemptive = (Boolean) getInputParameter(AUTH_PREEMPTIVE_INPUT_PARAMETER);
return preemptive != null ? preemptive : Boolean.TRUE;
}

protected final AuthorizationType getAuth_type() {
protected final AuthorizationType getAuthType() {
final String authType = (String) getInputParameter(AUTH_TYPE_PARAMETER);
return authType != null ? AuthorizationType.valueOf(authType) : AuthorizationType.NONE;
}

protected final java.lang.String getProxy_protocol() {
return (java.lang.String) getInputParameter(PROXY_PROTOCOL_INPUT_PARAMETER);
protected final java.lang.String getProxyProtocol() {
return (String) getInputParameter(PROXY_PROTOCOL_INPUT_PARAMETER);
}

protected final java.lang.String getProxy_host() {
return (java.lang.String) getInputParameter(PROXY_HOST_INPUT_PARAMETER);
protected final String getProxyHost() {
return (String) getInputParameter(PROXY_HOST_INPUT_PARAMETER);
}

protected final java.lang.Integer getProxy_port() {
return (java.lang.Integer) getInputParameter(PROXY_PORT_INPUT_PARAMETER);
protected final Integer getProxyPort() {
return (Integer) getInputParameter(PROXY_PORT_INPUT_PARAMETER);
}

protected final java.lang.String getProxy_username() {
return (java.lang.String) getInputParameter(PROXY_USERNAME_INPUT_PARAMETER);
protected final String getProxyUsername() {
return (String) getInputParameter(PROXY_USERNAME_INPUT_PARAMETER);
}

protected final java.lang.String getProxy_password() {
return (java.lang.String) getInputParameter(PROXY_PASSWORD_INPUT_PARAMETER);
protected final String getProxyPassword() {
return (String) getInputParameter(PROXY_PASSWORD_INPUT_PARAMETER);
}

protected final Integer getSocketTimeoutMs() {
Expand Down Expand Up @@ -297,87 +297,87 @@ public void validateInputParameters() throws ConnectorValidationException {
throw new ConnectorValidationException("TLS type is invalid");
}
try {
getTrust_self_signed_certificate();
getTrustSelfSignedCertificate();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("trust_self_signed_certificate type is invalid");
}
try {
getHostname_verifier();
getHostnameVerifier();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("hostname_verifier type is invalid");
}
try {
getTrust_store_file();
getTrustStoreFile();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("trust_store_file type is invalid");
}
try {
getTrust_store_password();
getTrustStorePassword();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("trust_store_password type is invalid");
}
try {
getKey_store_file();
getKeyStoreFile();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("key_store_file type is invalid");
}
try {
getKey_store_password();
getKeyStorePassword();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("key_store_password type is invalid");
}
try {
getAuth_username();
getAuthUsername();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("auth_basic_username type is invalid");
}
try {
getAuth_password();
getAuthPassword();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("auth_basic_password type is invalid");
}
try {
getAuth_host();
getAuthHost();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("auth_basic_host type is invalid");
}
try {
getAuth_port();
getAuthPort();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("auth_basic_port type is invalid");
}
try {
getAuth_realm();
getAuthRealm();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("auth_basic_realm type is invalid");
}
try {
getAuth_preemptive();
getAuthPreemptive();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("auth_basic_preemptive type is invalid");
}
try {
getProxy_protocol();
getProxyProtocol();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("proxy_protocol type is invalid");
}
try {
getProxy_host();
getProxyHost();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("proxy_host type is invalid");
}
try {
getProxy_port();
getProxyPort();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("proxy_port type is invalid");
}
try {
getProxy_username();
getProxyUsername();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("proxy_username type is invalid");
}
try {
getProxy_password();
getProxyPassword();
} catch (final ClassCastException cce) {
throw new ConnectorValidationException("proxy_password type is invalid");
}
Expand Down
Loading

0 comments on commit 6931d46

Please sign in to comment.