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
c048d79e
Commit
c048d79e
authored
Feb 23, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a dedicated HTTP function to add a header with a timestamp,
to avoid some pointless double-buffering.
parent
5fe64d62
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
+26
-9
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+2
-6
cache_http.c
bin/varnishd/cache/cache_http.c
+22
-0
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+1
-3
No files found.
bin/varnishd/cache/cache.h
View file @
c048d79e
...
...
@@ -830,6 +830,7 @@ int HTTP_Decode(struct http *to, const uint8_t *fm);
void
http_ForceHeader
(
struct
http
*
to
,
const
char
*
hdr
,
const
char
*
val
);
void
http_PrintfHeader
(
struct
http
*
to
,
const
char
*
fmt
,
...)
__printflike
(
2
,
3
);
void
http_TimeHeader
(
struct
http
*
to
,
const
char
*
fmt
,
double
now
);
void
http_SetHeader
(
struct
http
*
to
,
const
char
*
hdr
);
void
http_SetH
(
const
struct
http
*
to
,
unsigned
n
,
const
char
*
fm
);
void
http_ForceField
(
const
struct
http
*
to
,
unsigned
n
,
const
char
*
t
);
...
...
bin/varnishd/cache/cache_fetch.c
View file @
c048d79e
...
...
@@ -262,7 +262,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
{
int
i
,
do_ims
=
0
;
double
now
;
char
time_str
[
VTIM_FORMAT_SIZE
];
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
...
...
@@ -313,8 +312,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
*
* If we didn't get a Date header, we assign one here.
*/
VTIM_format
(
now
,
time_str
);
http_PrintfHeader
(
bo
->
beresp
,
"Date: %s"
,
time_str
);
http_TimeHeader
(
bo
->
beresp
,
"Date: "
,
now
);
}
/*
...
...
@@ -771,7 +769,6 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
ssize_t
l
,
ll
,
o
;
double
now
;
uint8_t
*
ptr
;
char
time_str
[
VTIM_FORMAT_SIZE
];
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
...
...
@@ -790,8 +787,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
HTTP_Setup
(
bo
->
beresp
,
bo
->
ws
,
bo
->
vsl
,
SLT_BerespMethod
);
http_PutResponse
(
bo
->
beresp
,
"HTTP/1.1"
,
503
,
"Backend fetch failed"
);
VTIM_format
(
now
,
time_str
);
http_PrintfHeader
(
bo
->
beresp
,
"Date: %s"
,
time_str
);
http_TimeHeader
(
bo
->
beresp
,
"Date: "
,
now
);
http_SetHeader
(
bo
->
beresp
,
"Server: Varnish"
);
bo
->
fetch_objcore
->
exp
.
t_origin
=
bo
->
t_prev
;
...
...
bin/varnishd/cache/cache_http.c
View file @
c048d79e
...
...
@@ -38,6 +38,7 @@
#include "vend.h"
#include "vct.h"
#include "vtim.h"
#define HTTPH(a, b, c) char b[] = "*" a ":";
#include "tbl/http_headers.h"
...
...
@@ -1112,6 +1113,27 @@ http_PrintfHeader(struct http *to, const char *fmt, ...)
to
->
nhd
++
;
}
void
http_TimeHeader
(
struct
http
*
to
,
const
char
*
fmt
,
double
now
)
{
char
*
p
;
CHECK_OBJ_NOTNULL
(
to
,
HTTP_MAGIC
);
p
=
WS_Alloc
(
to
->
ws
,
strlen
(
fmt
)
+
VTIM_FORMAT_SIZE
);
if
(
p
==
NULL
)
{
http_fail
(
to
);
VSLb
(
to
->
vsl
,
SLT_LostHeader
,
"%s"
,
fmt
);
return
;
}
strcpy
(
p
,
fmt
);
VTIM_format
(
now
,
strchr
(
p
,
'\0'
));
to
->
hd
[
to
->
nhd
].
b
=
p
;
to
->
hd
[
to
->
nhd
].
e
=
strchr
(
p
,
'\0'
);
to
->
hdf
[
to
->
nhd
]
=
0
;
http_VSLH
(
to
,
to
->
nhd
);
to
->
nhd
++
;
}
/*--------------------------------------------------------------------*/
void
...
...
bin/varnishd/cache/cache_req_fsm.c
View file @
c048d79e
...
...
@@ -171,7 +171,6 @@ cnt_deliver(struct worker *wrk, struct req *req)
static
enum
req_fsm_nxt
cnt_synth
(
struct
worker
*
wrk
,
struct
req
*
req
)
{
char
date
[
40
];
struct
http
*
h
;
double
now
;
...
...
@@ -189,8 +188,7 @@ cnt_synth(struct worker *wrk, struct req *req)
HTTP_Setup
(
req
->
resp
,
req
->
ws
,
req
->
vsl
,
SLT_RespMethod
);
h
=
req
->
resp
;
VTIM_format
(
now
,
date
);
http_PrintfHeader
(
h
,
"Date: %s"
,
date
);
http_TimeHeader
(
h
,
"Date: "
,
now
);
http_SetHeader
(
h
,
"Server: Varnish"
);
http_PrintfHeader
(
req
->
resp
,
"X-Varnish: %u"
,
VXID
(
req
->
vsl
->
wid
));
http_PutResponse
(
h
,
"HTTP/1.1"
,
req
->
err_code
,
req
->
err_reason
);
...
...
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