Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-esiextra
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-esiextra
Commits
34044a00
Commit
34044a00
authored
Nov 05, 2017
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update bodyhash to also work with trailers
parent
87ec239b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
vfp_bodyhash.c
src/vfp_bodyhash.c
+20
-8
No files found.
src/vfp_bodyhash.c
View file @
34044a00
...
...
@@ -83,6 +83,8 @@ vfp_bodyhash_fini(struct vfp_ctx *vc, struct vfp_entry *vfe)
{
struct
bodyhash
*
bh
;
unsigned
char
sha
[
VSHA256_LEN
];
const
ssize_t
hexl
=
VSHA256_LEN
*
2
+
3
;
char
hex
[
hexl
];
char
*
etag
,
*
p
;
int
i
;
ssize_t
l
;
...
...
@@ -96,6 +98,23 @@ vfp_bodyhash_fini(struct vfp_ctx *vc, struct vfp_entry *vfe)
CAST_OBJ_NOTNULL
(
bh
,
vfe
->
priv1
,
BODYHASH_MAGIC
);
vfe
->
priv1
=
NULL
;
VSHA256_Final
(
sha
,
&
bh
->
sha256ctx
);
p
=
hex
;
*
p
++
=
'"'
;
for
(
i
=
0
;
i
<
VSHA256_LEN
;
i
++
)
{
*
p
++
=
hexe
[(
sha
[
i
]
&
0xf0
)
>>
4
];
*
p
++
=
hexe
[
sha
[
i
]
&
0x0f
];
}
*
p
++
=
'"'
;
*
p
++
=
'\0'
;
assert
(
pdiff
(
hex
,
p
)
==
hexl
);
if
(
vc
->
resp
&&
vc
->
resp
->
thd
)
{
http_ForceHeader
(
vc
->
resp
,
H_ETag
,
hex
);
goto
out
;
}
// HACKY
p
=
TRUST_ME
(
ObjGetAttr
(
vc
->
wrk
,
vc
->
oc
,
OA_HEADERS
,
&
l
));
if
(
p
==
NULL
)
{
...
...
@@ -123,16 +142,9 @@ vfp_bodyhash_fini(struct vfp_ctx *vc, struct vfp_entry *vfe)
goto
out
;
}
VSHA256_Final
(
sha
,
&
bh
->
sha256ctx
);
assert
(
*
etag
==
'"'
);
p
=
etag
;
p
++
;
for
(
i
=
0
;
i
<
VSHA256_LEN
;
i
++
)
{
*
p
++
=
hexe
[(
sha
[
i
]
&
0xf0
)
>>
4
];
*
p
++
=
hexe
[
sha
[
i
]
&
0x0f
];
}
assert
(
*
p
==
'"'
);
memcpy
(
etag
,
hex
,
hexl
);
out:
FREE_OBJ
(
bh
);
...
...
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