mirror of
https://github.com/moparisthebest/spdylay
synced 2024-12-22 07:38:52 -05:00
Merge branch 'master' of https://github.com/sorced-jim/spdylay into sorced-jim-master
This commit is contained in:
commit
6cb4259232
@ -401,9 +401,10 @@ void* spdylay_session_get_stream_user_data(spdylay_session *session,
|
||||
* range of [0, 3]. 0 means the higest priority. |nv| must include
|
||||
* following name/value pairs:
|
||||
*
|
||||
* "method": HTTP method (e.g., "GET" or "POST")
|
||||
* "method": HTTP method (e.g., "GET", "POST", "HEAD", etc)
|
||||
* "scheme": URI scheme (e.g., "https")
|
||||
* "url": Absolute path of this request (e.g., "/foo")
|
||||
* "url": Absolute path and parameters of this request (e.g., "/foo",
|
||||
* "/foo;bar;haz?h=j&y=123")
|
||||
* "version": HTTP version (e.g., "HTTP/1.1")
|
||||
*
|
||||
* "host" name/value pair is also required by some hosts.
|
||||
@ -412,11 +413,12 @@ void* spdylay_session_get_stream_user_data(spdylay_session *session,
|
||||
* also lower-cases all names in |nv|.
|
||||
*
|
||||
* If |data_prd| is not NULL, it provides data which will be sent in
|
||||
* subsequent DATA frames. In this case, "POST" must be specified with
|
||||
* "method" key in |nv|. If |data_prd| is NULL, SYN_STREAM have
|
||||
* FLAG_FIN. |stream_user_data| can be an arbitrary pointer, which
|
||||
* can be retrieved by spdylay_session_get_stream_user_data(). Since
|
||||
* stream ID is not known before sending SYN_STREAM frame and the
|
||||
* subsequent DATA frames. In this case, a method that allows request
|
||||
* message bodies (http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9)
|
||||
* must be specified with "method" key in |nv| (e.g. POST). If |data_prd| is
|
||||
* NULL, SYN_STREAM have * FLAG_FIN. |stream_user_data| can be an arbitrary
|
||||
* pointer, which can be retrieved by spdylay_session_get_stream_user_data().
|
||||
* Since stream ID is not known before sending SYN_STREAM frame and the
|
||||
* application code has to compare url, and possibly other header
|
||||
* field values, to identify stream ID for the request in
|
||||
* spdylay_on_ctrl_send_callback(). With |stream_user_data|, the
|
||||
|
@ -124,7 +124,7 @@ int spdylay_submit_request(spdylay_session *session, uint8_t pri,
|
||||
if(pri > 3) {
|
||||
return SPDYLAY_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
if(data_prd) {
|
||||
if(data_prd != NULL && data_prd->read_callback != NULL) {
|
||||
data_prd_copy = malloc(sizeof(spdylay_data_provider));
|
||||
if(data_prd_copy == NULL) {
|
||||
return SPDYLAY_ERR_NOMEM;
|
||||
|
@ -134,6 +134,8 @@ int main(int argc, char* argv[])
|
||||
!CU_add_test(pSuite, "frame_nv_sort", test_spdylay_frame_nv_sort) ||
|
||||
!CU_add_test(pSuite, "frame_nv_downcase",
|
||||
test_spdylay_frame_nv_downcase) ||
|
||||
!CU_add_test(pSuite, "frame_nv_downcase",
|
||||
test_spdylay_frame_pack_nv_duplicate_keys) ||
|
||||
!CU_add_test(pSuite, "stream_add_pushed_stream",
|
||||
test_spdylay_stream_add_pushed_stream)) {
|
||||
CU_cleanup_registry();
|
||||
|
@ -60,6 +60,92 @@ void test_spdylay_frame_unpack_nv()
|
||||
spdylay_frame_nv_del(nv);
|
||||
}
|
||||
|
||||
void test_spdylay_frame_pack_nv_duplicate_keys()
|
||||
{
|
||||
int i;
|
||||
uint8_t out[1024];
|
||||
const char *nv_src[] = {
|
||||
"method", "GET",
|
||||
"scheme", "https",
|
||||
"url", "/",
|
||||
"X-hEad", "foo",
|
||||
"x-heaD", "bar",
|
||||
"version", "HTTP/1.1",
|
||||
NULL
|
||||
};
|
||||
char **nv = spdylay_frame_nv_copy(nv_src);
|
||||
spdylay_frame_nv_downcase(nv);
|
||||
spdylay_frame_nv_sort(nv);
|
||||
size_t inlen = spdylay_frame_pack_nv(out, nv);
|
||||
const uint8_t *outptr = out;
|
||||
int pairs = spdylay_get_uint16(outptr);
|
||||
CU_ASSERT(pairs == 5);
|
||||
outptr += 2;
|
||||
|
||||
int len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 6);
|
||||
CU_ASSERT(memcmp(outptr, "method", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 3);
|
||||
CU_ASSERT(memcmp(outptr, "GET", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 6);
|
||||
CU_ASSERT(memcmp(outptr, "scheme", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 5);
|
||||
CU_ASSERT(memcmp(outptr, "https", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 3);
|
||||
CU_ASSERT(memcmp(outptr, "url", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 1);
|
||||
CU_ASSERT(memcmp(outptr, "/", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 7);
|
||||
CU_ASSERT(memcmp(outptr, "version", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 8);
|
||||
CU_ASSERT(memcmp(outptr, "HTTP/1.1", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 6);
|
||||
CU_ASSERT(memcmp(outptr, "x-head", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
len = spdylay_get_uint16(outptr);
|
||||
outptr += 2;
|
||||
CU_ASSERT(len == 7);
|
||||
CU_ASSERT(memcmp(outptr, "foo\0bar", len) == 0);
|
||||
outptr += len;
|
||||
|
||||
spdylay_frame_nv_del(nv);
|
||||
}
|
||||
|
||||
void test_spdylay_frame_count_nv_space()
|
||||
{
|
||||
CU_ASSERT(83 == spdylay_frame_count_nv_space((char**)headers));
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define SPDYLAY_FRAME_TEST_H
|
||||
|
||||
void test_spdylay_frame_unpack_nv();
|
||||
void test_spdylay_frame_pack_nv_duplicate_keys();
|
||||
void test_spdylay_frame_count_nv_space();
|
||||
void test_spdylay_frame_count_unpack_nv_space();
|
||||
void test_spdylay_frame_pack_ping();
|
||||
|
Loading…
Reference in New Issue
Block a user