[homekit.binding] Increase maximum permitted HTTP content length#20212
[homekit.binding] Increase maximum permitted HTTP content length#20212jlaur merged 1 commit intoopenhab:mainfrom
Conversation
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
There was a problem hiding this comment.
Pull request overview
This PR updates the HomeKit binding’s HTTP payload parser to accept larger valid HomeKit HTTP bodies by increasing the maximum permitted content length.
Changes:
- Increased the maximum allowed HTTP content length from 64 KiB to 256 KiB.
- Enhanced exception messages to include actual/maximum sizes when payloads exceed the limit.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (chunkDataBuffer.size() > MAX_CONTENT_LENGTH) { | ||
| throw new IOException("Chunked data exceeds maximum allowed size"); | ||
| throw new IOException("Chunked data size %d exceeds maximum allowed %d" | ||
| .formatted(contentBuffer.size(), MAX_CONTENT_LENGTH)); |
There was a problem hiding this comment.
The chunked-size limit check is performed on chunkDataBuffer.size(), but the exception message formats contentBuffer.size(). This can report an unrelated (often smaller) value and make diagnosing oversize chunked payloads confusing. Use the same buffer size in the message as the one being validated (or report both if that's intended).
| .formatted(contentBuffer.size(), MAX_CONTENT_LENGTH)); | |
| .formatted(chunkDataBuffer.size(), MAX_CONTENT_LENGTH)); |
There was a problem hiding this comment.
Oops! @jlaur you were too fast ;) but I will fix it..
There was a problem hiding this comment.
Yeah, I missed that, AI beats me spotting such things. 😉 I don't know who requested the Copilot review, but I don't have access to do that myself.
There was a problem hiding this comment.
who requested the Copilot review
I did it myself.
but I don't have access to do that myself
I think any GitHub user can register their account to allow Copilot. It gives you a certain number of gratis requests per month which is sufficient (most months) for a binding contributor like me. However you may find that as a reviewer you may hit the limit sooner. But it is worth having anyway..
There was a problem hiding this comment.
PS I added the fix into #20209 which reverts the 11 digit pairing code stuff, and instead repurposes the PR for two minor tweaks.
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
The current maximum permitted HTTP content length is 64k bytes. However during testing I found one accessory that produces valid payloads over 100k bytes. This PR increases the maximum permitted HTTP content length limit from 64k bytes to 256k bytes.
Signed-off-by: Andrew Fiddian-Green software@whitebear.ch