mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Make charsetForEntityi a method, rather than hard-code UTF-8.
This commit is contained in:
@ -27,6 +27,7 @@ import java.io.Serializable;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -786,7 +787,7 @@ public class BaseAPIActionUtil
|
|||||||
try(CloseableHttpClient client = HttpClients.custom().setConnectionManager(new PoolingHttpClientConnectionManager()).build())
|
try(CloseableHttpClient client = HttpClients.custom().setConnectionManager(new PoolingHttpClientConnectionManager()).build())
|
||||||
{
|
{
|
||||||
HttpPost request = new HttpPost(fullURL);
|
HttpPost request = new HttpPost(fullURL);
|
||||||
request.setEntity(new StringEntity(postBody, StandardCharsets.UTF_8));
|
request.setEntity(new StringEntity(postBody, getCharsetForEntity()));
|
||||||
|
|
||||||
if(setCredentialsInHeader)
|
if(setCredentialsInHeader)
|
||||||
{
|
{
|
||||||
@ -829,6 +830,16 @@ public class BaseAPIActionUtil
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Let a subclass change what charset to use for entities (bodies) being posted/put/etc.
|
||||||
|
*******************************************************************************/
|
||||||
|
protected static Charset getCharsetForEntity()
|
||||||
|
{
|
||||||
|
return StandardCharsets.UTF_8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** one-line method, factored out so mock/tests can override
|
** one-line method, factored out so mock/tests can override
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -914,7 +925,7 @@ public class BaseAPIActionUtil
|
|||||||
body.put(wrapperObjectName, new JSONObject(json));
|
body.put(wrapperObjectName, new JSONObject(json));
|
||||||
json = body.toString();
|
json = body.toString();
|
||||||
}
|
}
|
||||||
return (new StringEntity(json, StandardCharsets.UTF_8));
|
return (new StringEntity(json, getCharsetForEntity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -943,7 +954,7 @@ public class BaseAPIActionUtil
|
|||||||
body.put(wrapperObjectName, new JSONArray(json));
|
body.put(wrapperObjectName, new JSONArray(json));
|
||||||
json = body.toString();
|
json = body.toString();
|
||||||
}
|
}
|
||||||
return (new StringEntity(json, StandardCharsets.UTF_8));
|
return (new StringEntity(json, getCharsetForEntity()));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user