Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
e8f56d91
Commit
e8f56d91
authored
Oct 26, 2022
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
range: Move more parsing logic to http_GetRange()
parent
3e0717e5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
22 deletions
+29
-22
cache.h
bin/varnishd/cache/cache.h
+2
-1
cache_http.c
bin/varnishd/cache/cache_http.c
+21
-1
cache_range.c
bin/varnishd/cache/cache_range.c
+5
-20
vrt.h
include/vrt.h
+1
-0
No files found.
bin/varnishd/cache/cache.h
View file @
e8f56d91
...
...
@@ -640,7 +640,8 @@ int http_GetHdrField(const struct http *hp, hdr_t,
double
http_GetHdrQ
(
const
struct
http
*
hp
,
hdr_t
,
const
char
*
field
);
ssize_t
http_GetContentLength
(
const
struct
http
*
hp
);
ssize_t
http_GetContentRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
);
const
char
*
http_GetRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
);
const
char
*
http_GetRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
,
ssize_t
len
);
uint16_t
http_GetStatus
(
const
struct
http
*
hp
);
int
http_IsStatus
(
const
struct
http
*
hp
,
int
);
void
http_SetStatus
(
struct
http
*
to
,
uint16_t
status
,
const
char
*
reason
);
...
...
bin/varnishd/cache/cache_http.c
View file @
e8f56d91
...
...
@@ -958,7 +958,7 @@ http_GetContentRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
}
const
char
*
http_GetRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
)
http_GetRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
,
ssize_t
len
)
{
ssize_t
tmp_lo
,
tmp_hi
;
const
char
*
b
,
*
t
;
...
...
@@ -1003,6 +1003,26 @@ http_GetRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
b
++
;
if
(
*
b
!=
'\0'
)
return
(
"Trailing stuff"
);
assert
(
*
lo
>=
-
1
);
assert
(
*
hi
>=
-
1
);
if
(
len
<=
0
)
return
(
NULL
);
// Allow 200 response
if
(
*
lo
<
0
)
{
assert
(
*
hi
>
0
);
*
lo
=
len
-
*
hi
;
if
(
*
lo
<
0
)
*
lo
=
0
;
*
hi
=
len
-
1
;
}
else
if
(
len
>=
0
&&
(
*
hi
>=
len
||
*
hi
<
0
))
{
*
hi
=
len
-
1
;
}
if
(
*
lo
>=
len
)
return
(
"low range beyond object"
);
return
(
NULL
);
}
...
...
bin/varnishd/cache/cache_range.c
View file @
e8f56d91
...
...
@@ -108,25 +108,13 @@ vrg_dorange(struct req *req, void **priv)
struct
vrg_priv
*
vrg_priv
;
const
char
*
err
;
err
=
http_GetRange
(
req
->
http
,
&
low
,
&
high
);
err
=
http_GetRange
(
req
->
http
,
&
low
,
&
high
,
req
->
resp_len
);
if
(
err
!=
NULL
)
return
(
err
);
assert
(
low
>=
-
1
);
assert
(
high
>=
-
1
);
if
(
low
<
0
)
{
if
(
req
->
resp_len
<
0
||
high
<
0
)
return
(
NULL
);
// Allow 200 response
assert
(
high
>
0
);
low
=
req
->
resp_len
-
high
;
if
(
low
<
0
)
low
=
0
;
high
=
req
->
resp_len
-
1
;
}
else
if
(
req
->
resp_len
>=
0
&&
(
high
>=
req
->
resp_len
||
high
<
0
))
high
=
req
->
resp_len
-
1
;
else
if
(
high
<
0
)
if
(
low
<
0
||
high
<
0
)
return
(
NULL
);
// Allow 200 response
/*
* else (bo != NULL) {
* We assume that the client knows what it's doing and trust
...
...
@@ -134,9 +122,6 @@ vrg_dorange(struct req *req, void **priv)
* }
*/
if
(
req
->
resp_len
>=
0
&&
low
>=
req
->
resp_len
)
return
(
"low range beyond object"
);
if
(
req
->
resp_len
>=
0
)
{
http_PrintfHeader
(
req
->
resp
,
"Content-Range: bytes %jd-%jd/%jd"
,
(
intmax_t
)
low
,
(
intmax_t
)
high
,
(
intmax_t
)
req
->
resp_len
);
...
...
@@ -268,7 +253,7 @@ VRG_CheckBo(struct busyobj *bo)
if
(
!
cache_param
->
http_range_support
)
return
(
0
);
err
=
http_GetRange
(
bo
->
bereq0
,
&
rlo
,
&
rhi
);
err
=
http_GetRange
(
bo
->
bereq0
,
&
rlo
,
&
rhi
,
-
1
);
clen
=
http_GetContentLength
(
bo
->
beresp
);
crlen
=
http_GetContentRange
(
bo
->
beresp
,
&
crlo
,
&
crhi
);
...
...
include/vrt.h
View file @
e8f56d91
...
...
@@ -58,6 +58,7 @@
* binary/load-time compatible, increment MAJOR version
*
* NEXT (2023-03-15)
* [cache.h] http_GetRange() changed
* 16.0 (2022-09-15)
* VMOD C-prototypes moved into JSON
* VRT_AddVDP() deprecated
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment