Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
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
esp
mongoose
Commits
ff85b802
Commit
ff85b802
authored
Jan 10, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using case-insensitive string comparison for connection: keep-alive
parent
e2b42e41
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
mongoose.c
mongoose.c
+20
-20
No files found.
mongoose.c
View file @
ff85b802
...
...
@@ -455,26 +455,6 @@ static void set_non_blocking_mode(sock_t sock) {
#endif
}
static
int
should_keep_alive
(
const
struct
mg_connection
*
conn
)
{
const
char
*
method
=
conn
->
request_method
;
const
char
*
http_version
=
conn
->
http_version
;
const
char
*
header
=
mg_get_header
(
conn
,
"Connection"
);
return
method
!=
NULL
&&
!
strcmp
(
method
,
"GET"
)
&&
((
header
!=
NULL
&&
!
mg_strcasecmp
(
header
,
"keep-alive"
))
||
(
header
==
NULL
&&
http_version
&&
!
strcmp
(
http_version
,
"1.1"
)));
}
static
const
char
*
suggest_connection_header
(
const
struct
mg_connection
*
conn
)
{
return
should_keep_alive
(
conn
)
?
"keep-alive"
:
"close"
;
}
static
void
mg_strlcpy
(
register
char
*
dst
,
register
const
char
*
src
,
size_t
n
)
{
for
(;
*
src
!=
'\0'
&&
n
>
1
;
n
--
)
{
*
dst
++
=
*
src
++
;
}
*
dst
=
'\0'
;
}
// A helper function for traversing a comma separated list of values.
// It returns a list pointer shifted to the next value, or NULL if the end
// of the list found.
...
...
@@ -1529,6 +1509,26 @@ static int convert_uri_to_file_name(struct connection *conn, char *buf,
return
0
;
}
static
int
should_keep_alive
(
const
struct
mg_connection
*
conn
)
{
const
char
*
method
=
conn
->
request_method
;
const
char
*
http_version
=
conn
->
http_version
;
const
char
*
header
=
mg_get_header
(
conn
,
"Connection"
);
return
method
!=
NULL
&&
!
strcmp
(
method
,
"GET"
)
&&
((
header
!=
NULL
&&
!
mg_strcasecmp
(
header
,
"keep-alive"
))
||
(
header
==
NULL
&&
http_version
&&
!
strcmp
(
http_version
,
"1.1"
)));
}
static
const
char
*
suggest_connection_header
(
const
struct
mg_connection
*
conn
)
{
return
should_keep_alive
(
conn
)
?
"keep-alive"
:
"close"
;
}
static
void
mg_strlcpy
(
register
char
*
dst
,
register
const
char
*
src
,
size_t
n
)
{
for
(;
*
src
!=
'\0'
&&
n
>
1
;
n
--
)
{
*
dst
++
=
*
src
++
;
}
*
dst
=
'\0'
;
}
int
mg_write
(
struct
mg_connection
*
c
,
const
void
*
buf
,
int
len
)
{
return
spool
(
&
((
struct
connection
*
)
c
)
->
remote_iobuf
,
buf
,
len
);
}
...
...
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