Skip to content
This repository
Browse code

protocol::add_response

  • Loading branch information...
commit 6a7a163224816d2b6a9b573f278ee588cbb27283 1 parent c5bf1d4
Alvaro Lopez Ortega authored February 13, 2012
6  cherokee/connection.h
@@ -22,8 +22,8 @@
22 22
  * 02110-1301, USA.
23 23
  */
24 24
 
25  
-#ifndef CHEROKEE_REQUEST_H
26  
-#define CHEROKEE_REQUEST_H
  25
+#ifndef CHEROKEE_CONNECTION_H
  26
+#define CHEROKEE_CONNECTION_H
27 27
 
28 28
 #include "common.h"
29 29
 #include "buffer.h"
@@ -81,4 +81,4 @@ void cherokee_connection_tx_add    (cherokee_connection_t *conn, ssize_t tx);
81 81
 
82 82
 CHEROKEE_END_DECLS
83 83
 
84  
-#endif /* CHEROKEE_REQUEST_H */
  84
+#endif /* CHEROKEE_CONNECTION_H */
15  cherokee/post.c
@@ -29,7 +29,7 @@
29 29
 #include "util.h"
30 30
 
31 31
 #define ENTRIES           "post"
32  
-#define HTTP_100_RESPONSE "HTTP/1.1 100 Continue" CRLF CRLF
  32
+// #define HTTP_100_RESPONSE "HTTP/1.1 100 Continue" CRLF CRLF
33 33
 
34 34
 
35 35
 /* Base functions
@@ -241,10 +241,11 @@ remove_surplus (cherokee_post_t    *post,
241 241
 ret_t
242 242
 cherokee_post_read_header (cherokee_post_t *post)
243 243
 {
244  
-	ret_t               ret;
245  
-	char               *info     = NULL;
246  
-	cuint_t             info_len = 0;
247  
-	cherokee_request_t *req      = REQ(post->conn);
  244
+	ret_t                  ret;
  245
+	char                  *info     = NULL;
  246
+	cuint_t                info_len = 0;
  247
+	cherokee_request_t    *req      = REQ(post->conn);
  248
+	cherokee_connection_t *conn     = REQ_CONN(post->conn);
248 249
 
249 250
 	switch (post->read_header_phase) {
250 251
 	case cherokee_post_read_header_init:
@@ -270,7 +271,9 @@ cherokee_post_read_header (cherokee_post_t *post)
270 271
 			return ret_ok;
271 272
 		}
272 273
 
273  
-		cherokee_buffer_add_str (&post->read_header_100cont, HTTP_100_RESPONSE);
  274
+//		cherokee_buffer_add_str (&post->read_header_100cont, HTTP_100_RESPONSE);
  275
+		cherokee_protocol_add_response (&conn->protocol, http_version_11, http_continue, NULL);
  276
+
274 277
 		post->read_header_phase = cherokee_post_read_header_100cont;
275 278
 
276 279
 	case cherokee_post_read_header_100cont:
20  cherokee/protocol.c
@@ -88,3 +88,23 @@ cherokee_protocol_dispatch (cherokee_protocol_t *proto)
88 88
 	SHOULDNT_HAPPEN;
89 89
 	return ret_error;
90 90
 }
  91
+
  92
+
  93
+ret_t
  94
+cherokee_protocol_add_response (cherokee_protocol_t     *proto,
  95
+				cherokee_http_version_t  version,
  96
+				cherokee_http_t          status,
  97
+				cherokee_buffer_t       *header)
  98
+{
  99
+	switch (PROTOCOL_BASE(proto)->type) {
  100
+	case proto_http:
  101
+		return cherokee_protocol_http_add_response (proto, version, status, header);
  102
+	case http_spdy:
  103
+		return cherokee_protocol_spdy_add_response (proto, version, status, header);
  104
+	default:
  105
+		break;
  106
+	}
  107
+
  108
+	SHOULDNT_HAPPEN;
  109
+	return ret_error;
  110
+}
5  cherokee/protocol.h
@@ -79,6 +79,11 @@ ret_t cherokee_protocol_mrproper (cherokee_protocol_t *proto);
79 79
 ret_t cherokee_protocol_set      (cherokee_protocol_t *proto, cherokee_protocol_type_t type);
80 80
 ret_t cherokee_protocol_dispatch (cherokee_protocol_t *proto);
81 81
 
  82
+ret_t cherokee_protocol_add_response (cherokee_protocol_t     *proto,
  83
+				      cherokee_http_version_t  version,
  84
+				      cherokee_http_t          status,
  85
+				      cherokee_buffer_t       *header);
  86
+
82 87
 CHEROKEE_END_DECLS
83 88
 
84 89
 #endif /* CHEROKEE_PROTOCOL_H */
37  cherokee/protocol_http.c
@@ -111,3 +111,40 @@ cherokee_protocol_http_dispatch (cherokee_protocol_t *proto)
111 111
 
112 112
 	return ret_ok;
113 113
 }
  114
+
  115
+
  116
+
  117
+ret_t
  118
+cherokee_protocol_http_add_response (cherokee_protocol_t     *proto,
  119
+				     cherokee_http_version_t  version,
  120
+				     cherokee_http_t          status,
  121
+				     cherokee_buffer_t       *header)
  122
+{
  123
+	ret_t                  ret;
  124
+	const char            *str;
  125
+	cuint_t               *str_len;
  126
+	cherokee_connection_t *conn   = CONN (PROTOCOL_BASE(proto)->conn);
  127
+
  128
+	/* Version */
  129
+	ret = cherokee_http_version_to_string (version, &str, &str_len);
  130
+	if (unlikely (ret != ret_ok))
  131
+		return ret;
  132
+
  133
+	cherokee_buffer_add      (&conn->buffer_out, str, str_len);
  134
+	cherokee_buffer_add_char (&conn->buffer_out, ' ');
  135
+
  136
+	/* Status */
  137
+	ret = cherokee_http_code_copy (status, &conn->buffer_out);
  138
+	if (unlikely (ret != ret_ok))
  139
+		return ret;
  140
+
  141
+	/* Headers */
  142
+	if (header != NULL) {
  143
+		cherokee_buffer_add_buf (&conn->buffer_out, header);
  144
+	}
  145
+
  146
+	/* End of header*/
  147
+	cherokee_buffer_add_str (&conn->buffer_out, CRLF_CRLF);
  148
+
  149
+	return ret_ok;
  150
+}
7  cherokee/protocol_http.h
@@ -29,7 +29,12 @@
29 29
 
30 30
 CHEROKEE_BEGIN_DECLS
31 31
 
32  
-ret_t cherokee_protocol_http_dispatch (cherokee_protocol_t *proto);
  32
+ret_t cherokee_protocol_http_dispatch     (cherokee_protocol_t     *proto);
  33
+
  34
+ret_t cherokee_protocol_http_add_response (cherokee_protocol_t     *proto,
  35
+					   cherokee_http_version_t  version,
  36
+					   cherokee_http_t          status,
  37
+					   cherokee_buffer_t       *header);
33 38
 
34 39
 CHEROKEE_END_DECLS
35 40
 
9  cherokee/protocol_spdy.c
@@ -31,3 +31,12 @@ cherokee_protocol_spdy_dispatch (cherokee_protocol_t *proto)
31 31
 {
32 32
 	return ret_ok;
33 33
 }
  34
+
  35
+ret_t
  36
+cherokee_protocol_spdy_add_response (cherokee_protocol_t     *proto,
  37
+				     cherokee_http_version_t  version,
  38
+				     cherokee_http_t          status,
  39
+				     cherokee_buffer_t       *header)
  40
+{
  41
+	return ret_ok;
  42
+}
7  cherokee/protocol_spdy.h
@@ -30,7 +30,12 @@
30 30
 
31 31
 CHEROKEE_BEGIN_DECLS
32 32
 
33  
-ret_t cherokee_protocol_spdy_dispatch (cherokee_protocol_t *proto);
  33
+ret_t cherokee_protocol_spdy_dispatch     (cherokee_protocol_t     *proto);
  34
+
  35
+ret_t cherokee_protocol_spdy_add_response (cherokee_protocol_t     *proto,
  36
+					   cherokee_http_version_t  version,
  37
+					   cherokee_http_t          status,
  38
+					   cherokee_buffer_t       *header);
34 39
 
35 40
 CHEROKEE_END_DECLS
36 41
 
1  cherokee/thread.h
@@ -38,6 +38,7 @@
38 38
 #include "fdpoll.h"
39 39
 #include "avl.h"
40 40
 #include "limiter.h"
  41
+#include "connection.h"
41 42
 
42 43
 
43 44
 typedef enum {
1  cherokee/trace.c
@@ -29,6 +29,7 @@
29 29
 #include "bogotime.h"
30 30
 #include "access.h"
31 31
 #include "socket.h"
  32
+#include "connection.h"
32 33
 #include "request-protected.h"
33 34
 
34 35
 #ifdef HAVE_SYSLOG_H

0 notes on commit 6a7a163

Please sign in to comment.
Something went wrong with that request. Please try again.