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
e68610a4
Commit
e68610a4
authored
Feb 25, 2021
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: New http_GetContentRange() helper
parent
723cd7b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_http.c
bin/varnishd/cache/cache_http.c
+64
-0
No files found.
bin/varnishd/cache/cache.h
View file @
e68610a4
...
...
@@ -606,6 +606,7 @@ int http_GetHdrField(const struct http *hp, hdr_t,
const
char
*
field
,
const
char
**
ptr
);
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
);
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 @
e68610a4
...
...
@@ -864,6 +864,70 @@ http_GetContentLength(const struct http *hp)
return
(
cl
);
}
ssize_t
http_GetContentRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
)
{
ssize_t
tmp
,
cl
;
const
char
*
b
;
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
if
(
lo
==
NULL
)
lo
=
&
tmp
;
if
(
hi
==
NULL
)
hi
=
&
tmp
;
*
lo
=
*
hi
=
-
1
;
if
(
!
http_GetHdr
(
hp
,
H_Content_Range
,
&
b
))
return
(
-
1
);
if
(
strncasecmp
(
"bytes"
,
b
,
strlen
(
"bytes"
)))
return
(
-
1
);
// Unknown range unit, ignore
b
+=
strlen
(
"bytes"
);
if
(
!
vct_islws
(
*
b
))
return
(
-
1
);
// Unknown range unit, ignore
while
(
vct_islws
(
*
b
))
b
++
;
if
(
*
b
==
'*'
)
{
// Content-Range: bytes */123
*
lo
=
*
hi
=
-
1
;
b
++
;
}
else
{
// Content-Range: bytes 1-2/3
*
lo
=
http_parse_uint
(
b
,
&
b
);
if
(
*
lo
<
0
)
return
(
-
2
);
if
(
*
b
!=
'-'
)
return
(
-
2
);
*
hi
=
http_parse_uint
(
b
+
1
,
&
b
);
if
(
*
hi
<
0
)
return
(
-
2
);
}
if
(
*
b
!=
'/'
)
return
(
-
2
);
if
(
b
[
1
]
==
'*'
)
{
// Content-Range: bytes 1-2/*
cl
=
-
1
;
b
+=
2
;
}
else
{
cl
=
http_parse_uint
(
b
+
1
,
&
b
);
if
(
cl
<=
0
)
return
(
-
2
);
}
while
(
vct_islws
(
*
b
))
b
++
;
if
(
*
b
!=
'\0'
)
return
(
-
2
);
if
(
*
lo
>
*
hi
)
return
(
-
2
);
assert
(
cl
>=
-
1
);
if
(
cl
==
-
1
)
return
(
-
1
);
if
(
*
lo
>=
cl
||
*
hi
>=
cl
)
return
(
-
2
);
AN
(
cl
);
return
(
cl
);
}
/*--------------------------------------------------------------------
*/
...
...
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