aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Uzunov <andrey.uzunov@gmail.com>2013-06-19 10:52:50 +0000
committerAndrey Uzunov <andrey.uzunov@gmail.com>2013-06-19 10:52:50 +0000
commitf49028e96f9165b653a966f0455aee54346a3faa (patch)
tree5913201e3bd897d885587b927cfeb93f1fc59a4b
parente354fc772d0c8403aee0bf99f5acc75256e6eadc (diff)
downloadlibmicrohttpd-f49028e96f9165b653a966f0455aee54346a3faa.tar.gz
libmicrohttpd-f49028e96f9165b653a966f0455aee54346a3faa.zip
spdy: ignore POST instead of abort and send 501 no implemented
-rw-r--r--src/microspdy/applicationlayer.c38
-rw-r--r--src/microspdy/session.c38
2 files changed, 73 insertions, 3 deletions
diff --git a/src/microspdy/applicationlayer.c b/src/microspdy/applicationlayer.c
index 4335fd69..e706a89d 100644
--- a/src/microspdy/applicationlayer.c
+++ b/src/microspdy/applicationlayer.c
@@ -31,6 +31,22 @@
31#include "session.h" 31#include "session.h"
32 32
33 33
34void
35spdy_callback_response_done(void *cls,
36 struct SPDY_Response *response,
37 struct SPDY_Request *request,
38 enum SPDY_RESPONSE_RESULT status,
39 bool streamopened)
40{
41 (void)cls;
42 (void)status;
43 (void)streamopened;
44
45 SPDY_destroy_request(request);
46 SPDY_destroy_response(response);
47}
48
49
34/** 50/**
35 * Callback called when new stream is created. It extracts the info from 51 * Callback called when new stream is created. It extracts the info from
36 * the stream to create (HTTP) request object and pass it to the client. 52 * the stream to create (HTTP) request object and pass it to the client.
@@ -136,6 +152,28 @@ spdy_handler_new_stream (void *cls,
136 152
137 return SPDY_YES; 153 return SPDY_YES;
138 } 154 }
155
156 //ignore everything but GET
157 if(strcasecmp("GET",method))
158 {
159 SPDYF_DEBUG("received method '%s'", method);
160 static char * html = "Method not implemented. libmicrospdy supports now only GET.";
161 struct SPDY_Response *response = SPDY_build_response(501, NULL, SPDY_HTTP_VERSION_1_1, NULL, html, strlen(html));
162 if(NULL==response)
163 {
164 SPDY_destroy_request(request);
165 return SPDY_YES;
166 }
167
168 if(SPDY_YES != SPDY_queue_response(request, response, true, false, &spdy_callback_response_done, NULL))
169 {
170 SPDY_destroy_response(response);
171 SPDY_destroy_request(request);
172 }
173
174 //SPDY_destroy_request(request);
175 return SPDY_YES;
176 }
139 177
140 //call client's callback function to notify 178 //call client's callback function to notify
141 daemon->new_request_cb(daemon->cls, 179 daemon->new_request_cb(daemon->cls,
diff --git a/src/microspdy/session.c b/src/microspdy/session.c
index 670b4cde..46c15a96 100644
--- a/src/microspdy/session.c
+++ b/src/microspdy/session.c
@@ -322,9 +322,40 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session)
322static void 322static void
323spdyf_handler_read_data (struct SPDY_Session *session) 323spdyf_handler_read_data (struct SPDY_Session *session)
324{ 324{
325 (void)session; 325 //just ignore the whole frame for now
326 //TODO ignore data frames for now 326 struct SPDYF_Data_Frame * frame;
327 SPDYF_PANIC("POST requests are Not yet implemented!"); 327
328 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status
329 || SPDY_SESSION_STATUS_WAIT_FOR_BODY == session->status,
330 "the function is called wrong");
331
332 SPDYF_DEBUG("DATA frame received (POST?). Ignoring");
333
334 //SPDYF_SIGINT("");
335
336 frame = (struct SPDYF_Data_Frame *)session->frame_handler_cls;
337
338 //handle subheaders
339 if(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status)
340 {
341 if(frame->length > SPDY_MAX_SUPPORTED_FRAME_SIZE)
342 {
343 session->status = SPDY_SESSION_STATUS_IGNORE_BYTES;
344 return;
345 }
346 else
347 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY;
348 }
349
350 //handle body
351
352 if(session->read_buffer_offset - session->read_buffer_beginning
353 >= frame->length)
354 {
355 session->read_buffer_beginning += frame->length;
356 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER;
357 free(frame);
358 }
328} 359}
329 360
330 361
@@ -1071,6 +1102,7 @@ SPDYF_session_idle (struct SPDY_Session *session)
1071 session->read_buffer + session->read_buffer_beginning, 1102 session->read_buffer + session->read_buffer_beginning,
1072 sizeof(struct SPDYF_Data_Frame)); 1103 sizeof(struct SPDYF_Data_Frame));
1073 session->read_buffer_beginning += sizeof(struct SPDYF_Data_Frame); 1104 session->read_buffer_beginning += sizeof(struct SPDYF_Data_Frame);
1105 SPDYF_DATA_FRAME_NTOH(data_frame);
1074 1106
1075 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY; 1107 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY;
1076 session->frame_handler = &spdyf_handler_read_data; 1108 session->frame_handler = &spdyf_handler_read_data;