Skip to content

Commit 2717980

Browse files
Fixed gzipped attachment not returning gzipped content.
1 parent 8ab6239 commit 2717980

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/com/couchbase/lite/internal/AttachmentInternal.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ public InputStream getContentInputStream() {
211211
return new ByteArrayInputStream(getContent());
212212
}
213213

214+
public InputStream getEncodedContentInputStream() { return new ByteArrayInputStream(getEncodedContent()); }
215+
214216
public URL getContentURL() throws MalformedURLException {
215217
String path = database.getAttachmentStore().getBlobPathForKey(blobKey);
216218
return path != null ? new File(path).toURI().toURL() : null;

src/main/java/com/couchbase/lite/router/Router.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,10 +2051,12 @@ public Status do_GET_Attachment(Database _db, String docID, String _attachmentNa
20512051
if (acceptEncoding != null && acceptEncoding.contains("gzip") &&
20522052
attachment.getEncoding() == AttachmentInternal.AttachmentEncoding.AttachmentEncodingGZIP) {
20532053
connection.getResHeader().add("Content-Encoding", "gzip");
2054+
connection.setResponseInputStream(attachment.getEncodedContentInputStream());
2055+
}
2056+
else {
2057+
connection.setResponseInputStream(attachment.getContentInputStream());
20542058
}
2055-
20562059
dontOverwriteBody = true;
2057-
connection.setResponseInputStream(attachment.getContentInputStream());
20582060
return new Status(Status.OK);
20592061

20602062
} catch (CouchbaseLiteException e) {

0 commit comments

Comments
 (0)