Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
de57b6ef
Commit
de57b6ef
authored
Jan 28, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort nv in spdylay_submit_request and spdylay_submit_response
parent
4c6765e1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
1 deletion
+41
-1
lib/spdylay_frame.c
lib/spdylay_frame.c
+12
-0
lib/spdylay_frame.h
lib/spdylay_frame.h
+5
-0
lib/spdylay_session.c
lib/spdylay_session.c
+2
-0
tests/main.c
tests/main.c
+2
-1
tests/spdylay_frame_test.c
tests/spdylay_frame_test.c
+19
-0
tests/spdylay_frame_test.h
tests/spdylay_frame_test.h
+1
-0
No files found.
lib/spdylay_frame.c
View file @
de57b6ef
...
...
@@ -337,6 +337,18 @@ char** spdylay_frame_nv_copy(const char **nv)
return
nnv
;
}
static
int
spdylay_string_compar
(
const
void
*
lhs
,
const
void
*
rhs
)
{
return
strcmp
(
*
(
char
**
)
lhs
,
*
(
char
**
)
rhs
);
}
void
spdylay_frame_nv_sort
(
char
**
nv
)
{
int
n
;
for
(
n
=
0
;
nv
[
n
];
++
n
);
qsort
(
nv
,
n
/
2
,
2
*
sizeof
(
char
*
),
spdylay_string_compar
);
}
void
spdylay_frame_syn_stream_init
(
spdylay_syn_stream
*
frame
,
uint8_t
flags
,
int32_t
stream_id
,
int32_t
assoc_stream_id
,
uint8_t
pri
,
char
**
nv
)
...
...
lib/spdylay_frame.h
View file @
de57b6ef
...
...
@@ -213,4 +213,9 @@ void spdylay_frame_nv_free(char **nv);
*/
char
**
spdylay_frame_nv_copy
(
const
char
**
nv
);
/*
* Sorts |nv| in the ascending order of name.
*/
void
spdylay_frame_nv_sort
(
char
**
nv
);
#endif
/* SPDYLAY_FRAME_H */
lib/spdylay_session.c
View file @
de57b6ef
...
...
@@ -1019,6 +1019,7 @@ int spdylay_submit_response(spdylay_session *session,
free
(
frame
);
return
SPDYLAY_ERR_NOMEM
;
}
spdylay_frame_nv_sort
(
nv_copy
);
if
(
data_prd
==
NULL
)
{
flags
|=
SPDYLAY_FLAG_FIN
;
}
...
...
@@ -1068,6 +1069,7 @@ int spdylay_submit_request(spdylay_session *session, uint8_t pri,
free
(
frame
);
return
SPDYLAY_ERR_NOMEM
;
}
spdylay_frame_nv_sort
(
nv_copy
);
/* When we support POST using spdylay_data_provider, flags should be
0 if data_prd is set. */
flags
|=
SPDYLAY_FLAG_FIN
;
...
...
tests/main.c
View file @
de57b6ef
...
...
@@ -91,7 +91,8 @@ int main()
test_spdylay_frame_count_nv_space
)
||
!
CU_add_test
(
pSuite
,
"frame_pack_ping"
,
test_spdylay_frame_pack_ping
)
||
!
CU_add_test
(
pSuite
,
"frame_pack_headers"
,
test_spdylay_frame_pack_headers
))
{
test_spdylay_frame_pack_headers
)
||
!
CU_add_test
(
pSuite
,
"frame_nv_sort"
,
test_spdylay_frame_nv_sort
))
{
CU_cleanup_registry
();
return
CU_get_error
();
}
...
...
tests/spdylay_frame_test.c
View file @
de57b6ef
...
...
@@ -99,3 +99,22 @@ void test_spdylay_frame_pack_headers()
spdylay_zlib_inflate_free
(
&
inflater
);
spdylay_zlib_deflate_free
(
&
deflater
);
}
void
test_spdylay_frame_nv_sort
()
{
char
*
nv
[
7
];
nv
[
0
]
=
(
char
*
)
"version"
;
nv
[
1
]
=
(
char
*
)
"HTTP/1.1"
;
nv
[
2
]
=
(
char
*
)
"method"
;
nv
[
3
]
=
(
char
*
)
"GET"
;
nv
[
4
]
=
(
char
*
)
"scheme"
;
nv
[
5
]
=
(
char
*
)
"https"
;
nv
[
6
]
=
NULL
;
spdylay_frame_nv_sort
(
nv
);
CU_ASSERT
(
strcmp
(
"method"
,
nv
[
0
])
==
0
);
CU_ASSERT
(
strcmp
(
"GET"
,
nv
[
1
])
==
0
);
CU_ASSERT
(
strcmp
(
"scheme"
,
nv
[
2
])
==
0
);
CU_ASSERT
(
strcmp
(
"https"
,
nv
[
3
])
==
0
);
CU_ASSERT
(
strcmp
(
"version"
,
nv
[
4
])
==
0
);
CU_ASSERT
(
strcmp
(
"HTTP/1.1"
,
nv
[
5
])
==
0
);
}
tests/spdylay_frame_test.h
View file @
de57b6ef
...
...
@@ -29,5 +29,6 @@ void test_spdylay_frame_unpack_nv();
void
test_spdylay_frame_count_nv_space
();
void
test_spdylay_frame_pack_ping
();
void
test_spdylay_frame_pack_headers
();
void
test_spdylay_frame_nv_sort
();
#endif
/* SPDYLAY_FRAME_TEST_H */
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