| `baseURL` | no | - | The base URL for this thing. Can be extended in channel-configuration. |
| `refresh` | no | 30 | Time in seconds between two refresh calls for the channels of this thing. |
| `timeout` | no | 3000 | Timeout for HTTP requests in ms. |
+| `bufferSize` | no | 2048 | The buffer size for the response data (in kB). |
| `username` | yes | - | Username for authentication (advanced parameter). |
| `password` | yes | - | Password for authentication (advanced parameter). |
| `authMode` | no | BASIC | Authentication mode, `BASIC` or `DIGEST` (advanced parameter). |
}
return null;
});
- request.send(new HttpResponseListener(f));
+ request.send(new HttpResponseListener(f, null, config.bufferSize));
} catch (IllegalArgumentException | URISyntaxException e) {
logger.warn("Creating request for '{}' failed: {}", commandUrl, e.getMessage());
}
public String username = "";
public String password = "";
- public HttpAuthMode authMode = HttpAuthMode.BASIC;
+ public HttpAuthMode authMode = HttpAuthMode.BASIC;
public HttpMethod commandMethod = HttpMethod.GET;
+ public int bufferSize = 2048;
public @Nullable String encoding = null;
public @Nullable String contentType = null;
private final CompletableFuture<@Nullable Content> future;
private final String fallbackEncoding;
- public HttpResponseListener(CompletableFuture<@Nullable Content> future) {
- this(future, null);
- }
-
- public HttpResponseListener(CompletableFuture<@Nullable Content> future, @Nullable String fallbackEncoding) {
+ /**
+ * the HttpResponseListener is responsible
+ *
+ * @param future Content future to complete with the result of the request
+ * @param fallbackEncoding a fallback encoding for the content (UTF-8 if null)
+ * @param bufferSize the buffer size for the content in kB (default 2048 kB)
+ */
+ public HttpResponseListener(CompletableFuture<@Nullable Content> future, @Nullable String fallbackEncoding,
+ int bufferSize) {
+ super(bufferSize * 1024);
this.future = future;
this.fallbackEncoding = fallbackEncoding != null ? fallbackEncoding : StandardCharsets.UTF_8.name();
}
private final String url;
private final HttpClient httpClient;
private final int timeout;
+ private final int bufferSize;
private final @Nullable String fallbackEncoding;
private final Set<Consumer<Content>> consumers = ConcurrentHashMap.newKeySet();
private final List<String> headers;
this.httpClient = httpClient;
this.url = url;
this.timeout = thingConfig.timeout;
+ this.bufferSize = thingConfig.bufferSize;
this.headers = thingConfig.headers;
fallbackEncoding = thingConfig.encoding;
logger.trace("Sending to '{}': {}", finalUrl, Util.requestToLogString(request));
}
- request.send(new HttpResponseListener(response, fallbackEncoding));
+ request.send(new HttpResponseListener(response, fallbackEncoding, bufferSize));
} catch (IllegalArgumentException | URISyntaxException e) {
logger.warn("Creating request for '{}' failed: {}", url, e.getMessage());
}
<description>The timeout in ms for each request</description>
<default>3000</default>
</parameter>
+ <parameter name="bufferSize" type="integer" min="0">
+ <label>Buffer Size</label>
+ <description>Size of the response buffer (default 2048 kB)</description>
+ <default>2048</default>
+ <advanced>true</advanced>
+ </parameter>
<parameter name="username" type="text">
<label>Username</label>
<description>Basic Authentication username</description>