Skip to content

Commit

Permalink
sending the correct content type of "application/pdf" for PDF files f…
Browse files Browse the repository at this point in the history
…or form-multipart posts
  • Loading branch information
rbri committed Oct 6, 2023
1 parent 7c19e26 commit 3a81693
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="3.7.0" date="October xx, 2023" description="Firefox 118, Bugfixes">
<action type="add" dev="rbri" issue="637">
Sending the correct content type of "application/pdf" for PDF files for form-multipart posts.
</action>
<action type="fix" dev="rbri">
Fixed a major leak - frame windows (incl. iframes) are still referenced by the web client
windows list after the parent was closed. In the end they are not garbage collected.
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/htmlunit/BrowserVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public final class BrowserVersion implements Serializable {
CHROME.registerUploadMimeType("jpeg", MimeType.IMAGE_JPEG);
CHROME.registerUploadMimeType("jpg", MimeType.IMAGE_JPEG);
CHROME.registerUploadMimeType("png", MimeType.IMAGE_PNG);
CHROME.registerUploadMimeType("pdf", "application/pdf");
CHROME.registerUploadMimeType("webp", "image/webp");
CHROME.registerUploadMimeType("mp4", "video/mp4");
CHROME.registerUploadMimeType("m4v", "video/mp4");
Expand Down Expand Up @@ -346,6 +347,7 @@ public final class BrowserVersion implements Serializable {
EDGE.registerUploadMimeType("jpeg", MimeType.IMAGE_JPEG);
EDGE.registerUploadMimeType("jpg", MimeType.IMAGE_JPEG);
EDGE.registerUploadMimeType("png", MimeType.IMAGE_PNG);
EDGE.registerUploadMimeType("pdf", "application/pdf");
EDGE.registerUploadMimeType("webp", "image/webp");
EDGE.registerUploadMimeType("mp4", "video/mp4");
EDGE.registerUploadMimeType("m4v", "video/mp4");
Expand All @@ -372,6 +374,7 @@ public final class BrowserVersion implements Serializable {
FIREFOX_ESR.registerUploadMimeType("gif", MimeType.IMAGE_GIF);
FIREFOX_ESR.registerUploadMimeType("jpeg", MimeType.IMAGE_JPEG);
FIREFOX_ESR.registerUploadMimeType("jpg", MimeType.IMAGE_JPEG);
FIREFOX_ESR.registerUploadMimeType("pdf", "application/pdf");
FIREFOX_ESR.registerUploadMimeType("mp4", "video/mp4");
FIREFOX_ESR.registerUploadMimeType("m4v", "video/mp4");
FIREFOX_ESR.registerUploadMimeType("m4a", "audio/mp4");
Expand All @@ -398,6 +401,7 @@ public final class BrowserVersion implements Serializable {
FIREFOX.registerUploadMimeType("gif", MimeType.IMAGE_GIF);
FIREFOX.registerUploadMimeType("jpeg", MimeType.IMAGE_JPEG);
FIREFOX.registerUploadMimeType("jpg", MimeType.IMAGE_JPEG);
FIREFOX.registerUploadMimeType("pdf", "application/pdf");
FIREFOX.registerUploadMimeType("mp4", "video/mp4");
FIREFOX.registerUploadMimeType("m4v", "video/mp4");
FIREFOX.registerUploadMimeType("m4a", "audio/mp4");
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/htmlunit/html/HtmlFileInput3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ public void contentTypeWebm() throws Exception {
contentType("webm");
}

/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = {"CONTENT_TYPE:application/pdf", "charset"},
IE = {"CONTENT_TYPE:application/octet-stream", "charset"})
public void contentTypePdf() throws Exception {
contentType("pdf");
}

/**
* @throws Exception if an error occurs
*/
Expand Down

0 comments on commit 3a81693

Please sign in to comment.