• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂508 (tree)
時間2012-06-24 17:06:38
作者ornse01

Log Message

add implied LWS token handling after chunk-size token.

Change Summary

差異

--- bchanf/trunk/src/http/test_http_transferdecoder.c (revision 507)
+++ bchanf/trunk/src/http/test_http_transferdecoder.c (revision 508)
@@ -114,6 +114,42 @@
114114 "\r\n"
115115 };
116116
117+LOCAL UB testdata_chunked_09[] = {
118+ "1A \r\n"
119+ "abcfefghijklmnopqrstuvwxyz\r\n"
120+ "1a \r\n"
121+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
122+ "000 \r\n"
123+ "\r\n"
124+};
125+
126+LOCAL UB testdata_chunked_10[] = {
127+ "1a ;name=value\r\n"
128+ "abcfefghijklmnopqrstuvwxyz\r\n"
129+ "1A ;name\r\n"
130+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
131+ "0 ;name=value\r\n"
132+ "\r\n"
133+};
134+
135+LOCAL UB testdata_chunked_11[] = {
136+ "1A\t\r\n"
137+ "abcfefghijklmnopqrstuvwxyz\r\n"
138+ "1a\t\t\r\n"
139+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
140+ "000\t\r\n"
141+ "\r\n"
142+};
143+
144+LOCAL UB testdata_chunked_12[] = {
145+ "1a\t;name=value\r\n"
146+ "abcfefghijklmnopqrstuvwxyz\r\n"
147+ "1A\t\t;name\r\n"
148+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
149+ "0\t;name=value\r\n"
150+ "\r\n"
151+};
152+
117153 LOCAL UNITTEST_RESULT test_http_transferdecoder_common_perone(HTTP_TRANSFERCODING_TYPE type, UB *testdata, W testdata_len, W devide_len, UB *expected, W expected_len)
118154 {
119155 http_transferdecoder_t decoder;
@@ -302,6 +338,42 @@
302338 return test_http_transferdecoder_common(HTTP_TRANSFERCODING_TYPE_CHUNKED, testdata, testdata_len, expected, expected_len);
303339 }
304340
341+LOCAL UNITTEST_RESULT test_http_transferdecoder_chunked_9()
342+{
343+ UB *testdata = testdata_chunked_09;
344+ W testdata_len = strlen(testdata_chunked_09);
345+ UB *expected = testdata_identity_01;
346+ W expected_len = strlen(testdata_identity_01);
347+ return test_http_transferdecoder_common(HTTP_TRANSFERCODING_TYPE_CHUNKED, testdata, testdata_len, expected, expected_len);
348+}
349+
350+LOCAL UNITTEST_RESULT test_http_transferdecoder_chunked_10()
351+{
352+ UB *testdata = testdata_chunked_10;
353+ W testdata_len = strlen(testdata_chunked_10);
354+ UB *expected = testdata_identity_01;
355+ W expected_len = strlen(testdata_identity_01);
356+ return test_http_transferdecoder_common(HTTP_TRANSFERCODING_TYPE_CHUNKED, testdata, testdata_len, expected, expected_len);
357+}
358+
359+LOCAL UNITTEST_RESULT test_http_transferdecoder_chunked_11()
360+{
361+ UB *testdata = testdata_chunked_11;
362+ W testdata_len = strlen(testdata_chunked_11);
363+ UB *expected = testdata_identity_01;
364+ W expected_len = strlen(testdata_identity_01);
365+ return test_http_transferdecoder_common(HTTP_TRANSFERCODING_TYPE_CHUNKED, testdata, testdata_len, expected, expected_len);
366+}
367+
368+LOCAL UNITTEST_RESULT test_http_transferdecoder_chunked_12()
369+{
370+ UB *testdata = testdata_chunked_12;
371+ W testdata_len = strlen(testdata_chunked_12);
372+ UB *expected = testdata_identity_01;
373+ W expected_len = strlen(testdata_identity_01);
374+ return test_http_transferdecoder_common(HTTP_TRANSFERCODING_TYPE_CHUNKED, testdata, testdata_len, expected, expected_len);
375+}
376+
305377 EXPORT VOID test_http_transferdecoder_main(unittest_driver_t *driver)
306378 {
307379 UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_identity_1);
@@ -313,4 +385,8 @@
313385 UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_6);
314386 UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_7);
315387 UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_8);
388+ UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_9);
389+ UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_10);
390+ UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_11);
391+ UNITTEST_DRIVER_REGIST(driver, test_http_transferdecoder_chunked_12);
316392 }
--- bchanf/trunk/src/http/http_transferdecoder.c (revision 507)
+++ bchanf/trunk/src/http/http_transferdecoder.c (revision 508)
@@ -116,7 +116,28 @@
116116 parser->state = HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_CR;
117117 break;
118118 }
119+ if ((ch == ' ')||(ch == '\t')) {
120+ parser->state = HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_IMPLIED_LWS;
121+ break;
122+ }
119123 return HTTP_CHUNKEDBODYPARSER_RESULT_ERROR;
124+ case HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_IMPLIED_LWS:
125+ if (ch == ';') {
126+ if (parser->chunk_size == 0) {
127+ parser->state = HTTP_CHUNKEDBODYPARSER_STATE_LAST_CHUNK_EXTENTION;
128+ } else {
129+ parser->state = HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_EXTENTION;
130+ }
131+ break;
132+ }
133+ if (ch == '\r') {
134+ parser->state = HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_CR;
135+ break;
136+ }
137+ if ((ch == ' ')||(ch == '\t')) {
138+ break;
139+ }
140+ return HTTP_CHUNKEDBODYPARSER_RESULT_ERROR;
120141 case HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_CR:
121142 DP_STATE("CHUNK_SIZE_CR");
122143 if (ch == '\n') {
--- bchanf/trunk/src/http/http_transferdecoder.h (revision 507)
+++ bchanf/trunk/src/http/http_transferdecoder.h (revision 508)
@@ -64,6 +64,7 @@
6464 struct http_chunkedbodyparser_t_ {
6565 enum {
6666 HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE,
67+ HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_IMPLIED_LWS,
6768 HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_SIZE_CR,
6869 HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_DATA,
6970 HTTP_CHUNKEDBODYPARSER_STATE_CHUNK_DATA_END,
Show on old repository browser