Title: Endpoint can't parse multipart requests with Content-Disposition: attachment · Issue #11 · swordapp/JavaServer2.0 · GitHub
Open Graph Title: Endpoint can't parse multipart requests with Content-Disposition: attachment · Issue #11 · swordapp/JavaServer2.0
X Title: Endpoint can't parse multipart requests with Content-Disposition: attachment · Issue #11 · swordapp/JavaServer2.0
Description: Posting a multipart request with Content-Disposition: attachment, as specified by e.g. Section 6.5.3 of the SWORD 2.0 Profile: The client MUST supply a Content-Disposition header of type attachment on the Entry Part with a name parameter...
Open Graph Description: Posting a multipart request with Content-Disposition: attachment, as specified by e.g. Section 6.5.3 of the SWORD 2.0 Profile: The client MUST supply a Content-Disposition header of type attachment...
X Description: Posting a multipart request with Content-Disposition: attachment, as specified by e.g. Section 6.5.3 of the SWORD 2.0 Profile: The client MUST supply a Content-Disposition header of type attachment...
Opengraph URL: https://github.com/swordapp/JavaServer2.0/issues/11
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Endpoint can't parse multipart requests with Content-Disposition: attachment","articleBody":"Posting a multipart request with `Content-Disposition: attachment`, as specified by e.g. [Section 6.5.3](http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_editingcontent_multipart) of the SWORD 2.0 Profile:\n\n> - The client MUST supply a Content-Disposition header of type attachment on the Entry Part with a name parameter set to atom [SWORD004]\n> - The client MUST supply a Content-Disposition header of type attachment on the Media Part with a name parameter set to payload and a filename parameter [SWORD004] \n\nresults in an exception with the message `Attempting to store and check deposit which has no input stream`.\n\nThe underlying cause appears to be Commons-Fileupload bug [FILEUPLOAD-239](https://issues.apache.org/jira/browse/FILEUPLOAD-239), closed as invalid based on (IMO) a misreading of [RFC 1867](http://www.ietf.org/rfc/rfc1867.txt), which accepts only `Content-Disposition: form-data`. I was able to work around this by patching [`SwordAPIEndpoint.getPartsFromRequest()`](https://github.com/swordapp/JavaServer2.0/blob/06d04f5e959465ae577f40a891ff6c930df2cd5e/src/main/java/org/swordapp/server/SwordAPIEndpoint.java#L465) with a more liberal `getFieldName()` implementation.\n\n``` java\n// Create a new file upload handler\nServletFileUpload upload = new ServletFileUpload(factory) {\n // Work around WONTFIX https://issues.apache.org/jira/browse/FILEUPLOAD-239\n @Override\n protected String getFieldName(FileItemHeaders headers) {\n String contentDisposition = headers.getHeader(CONTENT_DISPOSITION);\n if (contentDisposition != null) {\n ParameterParser parser = new ParameterParser();\n parser.setLowerCaseNames(true);\n Map params = parser.parse(contentDisposition, ';');\n String fieldName = (String) params.get(\"name\");\n if (fieldName != null) {\n return fieldName.trim();\n }\n }\n return null;\n }\n};\n```\n","author":{"url":"https://github.com/dmolesUC","@type":"Person","name":"dmolesUC"},"datePublished":"2016-06-27T18:02:12Z","url":"https://github.com/swordapp/JavaServer2.0/issues/11"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d9a7b160-4001-732c-fe70-bd4b049dff2c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD50:3C21B:4E111B:669828:6B00CADC |
| html-safe-nonce | 201d1fb2d67e5e6a929d3a9ce83ae6f9bf203a5e28ecaa954f7f0906b0d7d5ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDUwOjNDMjFCOjRFMTExQjo2Njk4Mjg6NkIwMENBREMiLCJ2aXNpdG9yX2lkIjoiODgyNzE2NjI0MDUxMTQxMjk1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 358e9014bec526df9e9aeafd1a4ef9717fbda72b305c0d687bf497766bf5ccf2 |
| hovercard-subject-tag | issue:162511699 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/swordapp/JavaServer2.0/11/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2ab4ef004753706605b5de825e253ccef288be635fce7752477d811ad557bda5/swordapp/JavaServer2.0/issues/11 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2ab4ef004753706605b5de825e253ccef288be635fce7752477d811ad557bda5/swordapp/JavaServer2.0/issues/11 |
| og:image:alt | Posting a multipart request with Content-Disposition: attachment, as specified by e.g. Section 6.5.3 of the SWORD 2.0 Profile: The client MUST supply a Content-Disposition header of type attachment... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dmolesUC |
| hostname | github.com |
| expected-hostname | github.com |
| None | 98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4 |
| turbo-cache-control | no-preview |
| go-import | github.com/swordapp/JavaServer2.0 git https://github.com/swordapp/JavaServer2.0.git |
| octolytics-dimension-user_id | 1606751 |
| octolytics-dimension-user_login | swordapp |
| octolytics-dimension-repository_id | 4202272 |
| octolytics-dimension-repository_nwo | swordapp/JavaServer2.0 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 4202272 |
| octolytics-dimension-repository_network_root_nwo | swordapp/JavaServer2.0 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ef013399cf0a3c324bea644a685d7c1e0f06b5b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width