Skip to content

send 416 error to overlapping ranges request#782

Closed
Chenjp wants to merge 3 commits into
apache:mainfrom
Chenjp:overlap_ranges_416
Closed

send 416 error to overlapping ranges request#782
Chenjp wants to merge 3 commits into
apache:mainfrom
Chenjp:overlap_ranges_416

Conversation

@Chenjp

@Chenjp Chenjp commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

request ranges validation - overlap detection added.

  • invalid ranges - overlapping:
D:\git\github.com>curl http://localhost:55464/index.html -i -H "Range: bytes=10-40,35-50"
HTTP/1.1 416
Accept-Ranges: bytes
Content-Range: bytes */957
Content-Type: text/html;charset=utf-8
Content-Language: zh-CN
Content-Length: 753
Date: Tue, 19 Nov 2024 03:03:56 GMT
  • valid ranges:
D:\git\github.com>curl http://localhost:55464/index.html -i -H "Range: bytes=10-40,50-60"
HTTP/1.1 206
Accept-Ranges: bytes
ETag: W/"957-1724403887512"
Last-Modified: Fri, 23 Aug 2024 09:04:47 GMT
Content-Type: multipart/byteranges; boundary=CATALINA_MIME_BOUNDARY
Content-Length: 194
Date: Tue, 19 Nov 2024 03:04:39 GMT


--CATALINA_MIME_BOUNDARY
Content-Range: bytes 10-40/957

censed to the Apache Software F
--CATALINA_MIME_BOUNDARY
Content-Range: bytes 50-60/957

 (ASF) unde
--CATALINA_MIME_BOUNDARY--

add overlapping ranges validation.
@gmshake

gmshake commented Nov 19, 2024

Copy link
Copy Markdown

Nice catch!

@markt-asf markt-asf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see similar protection for Content-Range when used with partial PUT.

for (Ranges.Entry range : ranges.getEntries()) {
long start = getStart(range, length);
long end = getEnd(range, length);
if (start < 0 || start > end) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this optimisation

Comment thread java/org/apache/catalina/servlets/DefaultServlet.java Outdated
update overlap ranges check.
@Chenjp

Chenjp commented Nov 23, 2024

Copy link
Copy Markdown
Contributor Author

I'd like to see similar protection for Content-Range when used with partial PUT.

@markt-asf done with PR #778
Only one content-range ( bytes {start}-{end}/{length} ) is allowed in partial PUT.

markt-asf added a commit that referenced this pull request Nov 27, 2024
markt-asf added a commit that referenced this pull request Nov 27, 2024
markt-asf added a commit that referenced this pull request Nov 27, 2024
markt-asf added a commit that referenced this pull request Nov 27, 2024
@markt-asf

Copy link
Copy Markdown
Contributor

Tx. Applied a variation manually.

@markt-asf markt-asf closed this Nov 27, 2024
@Chenjp
Chenjp deleted the overlap_ranges_416 branch February 11, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants