frankgh commented on code in PR #91:
URL: https://github.com/apache/cassandra-sidecar/pull/91#discussion_r1462703925
##########
src/main/java/org/apache/cassandra/sidecar/models/HttpResponse.java:
##########
@@ -97,17 +97,23 @@ public void setInternalErrorStatus(String msg)
*/
public Future<Void> sendFile(String fileName, long fileLength, HttpRange
range)
{
- // notify client we support range requests
- response.putHeader(HttpHeaderNames.ACCEPT_RANGES, "bytes");
-
- if (range.length() != fileLength)
- {
- setPartialContentStatus(range);
- }
-
- return response.putHeader(HttpHeaderNames.CONTENT_TYPE,
HttpHeaderValues.APPLICATION_OCTET_STREAM)
- .putHeader(HttpHeaderNames.CONTENT_LENGTH,
Long.toString(range.length()))
- .sendFile(fileName, range.start(), range.length());
+ // Defer setting headers in case of an error before sending the file
+ response.headersEndHandler(v -> {
+ // notify client we support range requests
+ response.putHeader(HttpHeaderNames.ACCEPT_RANGES, "bytes");
+
+ if (range.length() != fileLength)
+ {
+ setPartialContentStatus(range);
+ }
+ response.putHeader(HttpHeaderNames.CONTENT_TYPE,
HttpHeaderValues.APPLICATION_OCTET_STREAM)
+ .putHeader(HttpHeaderNames.CONTENT_LENGTH,
Long.toString(range.length()));
Review Comment:
ok, maybe we should let vertx set those headers. Thanks for catching it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]