X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_message_api.c;h=7f22d17095d1a5afb90da96969edc411914e2e73;hp=a0f5e59ada74c8a79fa40d0ef693dd0b2eb7b117;hb=6a5ec2c676458f24e191801ee20bce02691138b6;hpb=16ea91ddd08d15dd9b7206229fec6158f212adaf diff --git a/http_message_api.c b/http_message_api.c index a0f5e59..7f22d17 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -59,14 +59,14 @@ static void _http_message_headers_cb(const char *http_line, HashTable **headers, // response if (!strncmp(http_line, "HTTP/1.", lenof("HTTP/1."))) { new->type = HTTP_MSG_RESPONSE; - new->info.response.http_version = atof(http_line + lenof("HTTP/")); + new->info.response.http_version = (float) atof(http_line + lenof("HTTP/")); new->info.response.code = atoi(http_line + lenof("HTTP/1.1 ")); } else // request if (!strncmp(http_line + line_length - lenof("HTTP/1.1"), "HTTP/1.", lenof("HTTP/1."))) { const char *method_sep_uri = strchr(http_line, ' '); new->type = HTTP_MSG_REQUEST; - new->info.request.http_version = atof(http_line + line_length - lenof("1.1")); + new->info.request.http_version = (float) atof(http_line + line_length - lenof("1.1")); new->info.request.method = estrndup(http_line, method_sep_uri - http_line); new->info.request.URI = estrndup(method_sep_uri + 1, http_line + line_length - method_sep_uri - 1 - lenof(" HTTP/1.1")); } @@ -412,6 +412,21 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) return rs; } +PHP_HTTP_API http_message *_http_message_dup(http_message *msg TSRMLS_DC) +{ + /* + * TODO: unroll + */ + http_message *new; + char *serialized_data; + size_t serialized_length; + + http_message_serialize(msg, &serialized_data, &serialized_length); + new = http_message_parse(serialized_data, serialized_length); + efree(serialized_data); + return new; +} + PHP_HTTP_API void _http_message_dtor(http_message *message) { if (message) {