Title: Allow for an unknown content length. by twalmsley · Pull Request #127 · dnsjava/dnsjava · GitHub
Open Graph Title: Allow for an unknown content length. by twalmsley · Pull Request #127 · dnsjava/dnsjava
X Title: Allow for an unknown content length. by twalmsley · Pull Request #127 · dnsjava/dnsjava
Description: My DoH service works fine when accessed directly, but when it is behind an API gateway the response content length is unknown, so conn.getContentLength() returns -1 which causes an exception to be thrown. I have 2 suggested changes here: When the content length is unknown, just create a fixed size buffer for the response. I have chosen a maximum size that seems sensible to me, and I know I could have made it dynamic, but I think even in that case there would still be a need for a sensible maximum buffer size. I can change this if needed. When reading from the connection stream, it is always trying to read responseBytes.length bytes, but if it has already read some bytes then there will be no room for that number of bytes, so I have used the offset to reduce this as bytes are read into the buffer. I realise that if the content length is known then it won't read more than the expected number of bytes, but in the case when the length is not known it will be possible to read more bytes than the allocated buffer size, hence the check. I have tested this against https://dns.google/dns-query which does return a valid content length, as well as my own service behind an API gateway which returns -1 for the content length, and it succeeds in both cases.
Open Graph Description: My DoH service works fine when accessed directly, but when it is behind an API gateway the response content length is unknown, so conn.getContentLength() returns -1 which causes an exception to be ...
X Description: My DoH service works fine when accessed directly, but when it is behind an API gateway the response content length is unknown, so conn.getContentLength() returns -1 which causes an exception to be ...
Opengraph URL: https://github.com/dnsjava/dnsjava/pull/127
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:84f9d472-1752-7715-5013-9835d5c96897 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CA8E:17B76C:10F2431:1676A47:6B06549E |
| html-safe-nonce | 86a9702203feffa4b47603b5baf53775e2d09b137652f0caf188e8e364fa60db |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQThFOjE3Qjc2QzoxMEYyNDMxOjE2NzZBNDc6NkIwNjU0OUUiLCJ2aXNpdG9yX2lkIjoiMzU3NjEwNjQ4Mjg2NjgwMjIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7d210bc75233295be890fab5fd3bbf4080fb8e6449ca12f5076e2eff06b3ff58 |
| hovercard-subject-tag | pull_request:482060112 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/dnsjava/dnsjava/pull/127/files |
| twitter:image | https://avatars.githubusercontent.com/u/2378576?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2378576?s=400&v=4 |
| og:image:alt | My DoH service works fine when accessed directly, but when it is behind an API gateway the response content length is unknown, so conn.getContentLength() returns -1 which causes an exception to be ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/dnsjava/dnsjava git https://github.com/dnsjava/dnsjava.git |
| octolytics-dimension-user_id | 6755615 |
| octolytics-dimension-user_login | dnsjava |
| octolytics-dimension-repository_id | 17084567 |
| octolytics-dimension-repository_nwo | dnsjava/dnsjava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17084567 |
| octolytics-dimension-repository_network_root_nwo | dnsjava/dnsjava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width