Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

protocol::add_response

  • Loading branch information...
commit 6a7a163224816d2b6a9b573f278ee588cbb27283 1 parent c5bf1d4
@alobbs alobbs authored
View
6 cherokee/connection.h
@@ -22,8 +22,8 @@
* 02110-1301, USA.
*/
-#ifndef CHEROKEE_REQUEST_H
-#define CHEROKEE_REQUEST_H
+#ifndef CHEROKEE_CONNECTION_H
+#define CHEROKEE_CONNECTION_H
#include "common.h"
#include "buffer.h"
@@ -81,4 +81,4 @@ void cherokee_connection_tx_add (cherokee_connection_t *conn, ssize_t tx);
CHEROKEE_END_DECLS
-#endif /* CHEROKEE_REQUEST_H */
+#endif /* CHEROKEE_CONNECTION_H */
View
15 cherokee/post.c
@@ -29,7 +29,7 @@
#include "util.h"
#define ENTRIES "post"
-#define HTTP_100_RESPONSE "HTTP/1.1 100 Continue" CRLF CRLF
+// #define HTTP_100_RESPONSE "HTTP/1.1 100 Continue" CRLF CRLF
/* Base functions
@@ -241,10 +241,11 @@ remove_surplus (cherokee_post_t *post,
ret_t
cherokee_post_read_header (cherokee_post_t *post)
{
- ret_t ret;
- char *info = NULL;
- cuint_t info_len = 0;
- cherokee_request_t *req = REQ(post->conn);
+ ret_t ret;
+ char *info = NULL;
+ cuint_t info_len = 0;
+ cherokee_request_t *req = REQ(post->conn);
+ cherokee_connection_t *conn = REQ_CONN(post->conn);
switch (post->read_header_phase) {
case cherokee_post_read_header_init:
@@ -270,7 +271,9 @@ cherokee_post_read_header (cherokee_post_t *post)
return ret_ok;
}
- cherokee_buffer_add_str (&post->read_header_100cont, HTTP_100_RESPONSE);
+// cherokee_buffer_add_str (&post->read_header_100cont, HTTP_100_RESPONSE);
+ cherokee_protocol_add_response (&conn->protocol, http_version_11, http_continue, NULL);
+
post->read_header_phase = cherokee_post_read_header_100cont;
case cherokee_post_read_header_100cont:
View
20 cherokee/protocol.c
@@ -88,3 +88,23 @@ cherokee_protocol_dispatch (cherokee_protocol_t *proto)
SHOULDNT_HAPPEN;
return ret_error;
}
+
+
+ret_t
+cherokee_protocol_add_response (cherokee_protocol_t *proto,
+ cherokee_http_version_t version,
+ cherokee_http_t status,
+ cherokee_buffer_t *header)
+{
+ switch (PROTOCOL_BASE(proto)->type) {
+ case proto_http:
+ return cherokee_protocol_http_add_response (proto, version, status, header);
+ case http_spdy:
+ return cherokee_protocol_spdy_add_response (proto, version, status, header);
+ default:
+ break;
+ }
+
+ SHOULDNT_HAPPEN;
+ return ret_error;
+}
View
5 cherokee/protocol.h
@@ -79,6 +79,11 @@ ret_t cherokee_protocol_mrproper (cherokee_protocol_t *proto);
ret_t cherokee_protocol_set (cherokee_protocol_t *proto, cherokee_protocol_type_t type);
ret_t cherokee_protocol_dispatch (cherokee_protocol_t *proto);
+ret_t cherokee_protocol_add_response (cherokee_protocol_t *proto,
+ cherokee_http_version_t version,
+ cherokee_http_t status,
+ cherokee_buffer_t *header);
+
CHEROKEE_END_DECLS
#endif /* CHEROKEE_PROTOCOL_H */
View
37 cherokee/protocol_http.c
@@ -111,3 +111,40 @@ cherokee_protocol_http_dispatch (cherokee_protocol_t *proto)
return ret_ok;
}
+
+
+
+ret_t
+cherokee_protocol_http_add_response (cherokee_protocol_t *proto,
+ cherokee_http_version_t version,
+ cherokee_http_t status,
+ cherokee_buffer_t *header)
+{
+ ret_t ret;
+ const char *str;
+ cuint_t *str_len;
+ cherokee_connection_t *conn = CONN (PROTOCOL_BASE(proto)->conn);
+
+ /* Version */
+ ret = cherokee_http_version_to_string (version, &str, &str_len);
+ if (unlikely (ret != ret_ok))
+ return ret;
+
+ cherokee_buffer_add (&conn->buffer_out, str, str_len);
+ cherokee_buffer_add_char (&conn->buffer_out, ' ');
+
+ /* Status */
+ ret = cherokee_http_code_copy (status, &conn->buffer_out);
+ if (unlikely (ret != ret_ok))
+ return ret;
+
+ /* Headers */
+ if (header != NULL) {
+ cherokee_buffer_add_buf (&conn->buffer_out, header);
+ }
+
+ /* End of header*/
+ cherokee_buffer_add_str (&conn->buffer_out, CRLF_CRLF);
+
+ return ret_ok;
+}
View
7 cherokee/protocol_http.h
@@ -29,7 +29,12 @@
CHEROKEE_BEGIN_DECLS
-ret_t cherokee_protocol_http_dispatch (cherokee_protocol_t *proto);
+ret_t cherokee_protocol_http_dispatch (cherokee_protocol_t *proto);
+
+ret_t cherokee_protocol_http_add_response (cherokee_protocol_t *proto,
+ cherokee_http_version_t version,
+ cherokee_http_t status,
+ cherokee_buffer_t *header);
CHEROKEE_END_DECLS
View
9 cherokee/protocol_spdy.c
@@ -31,3 +31,12 @@ cherokee_protocol_spdy_dispatch (cherokee_protocol_t *proto)
{
return ret_ok;
}
+
+ret_t
+cherokee_protocol_spdy_add_response (cherokee_protocol_t *proto,
+ cherokee_http_version_t version,
+ cherokee_http_t status,
+ cherokee_buffer_t *header)
+{
+ return ret_ok;
+}
View
7 cherokee/protocol_spdy.h
@@ -30,7 +30,12 @@
CHEROKEE_BEGIN_DECLS
-ret_t cherokee_protocol_spdy_dispatch (cherokee_protocol_t *proto);
+ret_t cherokee_protocol_spdy_dispatch (cherokee_protocol_t *proto);
+
+ret_t cherokee_protocol_spdy_add_response (cherokee_protocol_t *proto,
+ cherokee_http_version_t version,
+ cherokee_http_t status,
+ cherokee_buffer_t *header);
CHEROKEE_END_DECLS
View
1  cherokee/thread.h
@@ -38,6 +38,7 @@
#include "fdpoll.h"
#include "avl.h"
#include "limiter.h"
+#include "connection.h"
typedef enum {
View
1  cherokee/trace.c
@@ -29,6 +29,7 @@
#include "bogotime.h"
#include "access.h"
#include "socket.h"
+#include "connection.h"
#include "request-protected.h"
#ifdef HAVE_SYSLOG_H
Please sign in to comment.
Something went wrong with that request. Please try again.