Permalink
Browse files

Namespace clean up: Renames cherokee_request_t to

cherokee_client_request_t.
  • Loading branch information...
1 parent 9a8b349 commit 83ce154ce6626c1ee5b379749488c30076c9598e @alobbs alobbs committed Jan 8, 2012
Showing with 28 additions and 327 deletions.
  1. +1 −1 cget/main.c
  2. +2 −2 cherokee/Makefile.am
  3. +16 −16 cherokee/downloader-protected.h
  4. +9 −9 cherokee/downloader.c
  5. +0 −226 cherokee/request.c
  6. +0 −73 cherokee/request.h
View
@@ -56,7 +56,7 @@
#include "url.h"
#include "header.h"
#include "fdpoll.h"
-#include "request.h"
+#include "client_request.h"
#include "downloader.h"
#include "downloader-protected.h"
#include "socket.h"
@@ -1448,8 +1448,8 @@ shm.c
libcherokee_client_la_SOURCES = \
url.h \
url.c \
-request.h \
-request.c \
+client_request.h \
+client_request.c \
downloader.h \
downloader-protected.h \
downloader.c \
@@ -28,7 +28,7 @@
#include "common-internal.h"
#include "buffer.h"
-#include "request.h"
+#include "client_request.h"
#include "socket.h"
#include "header.h"
#include "post.h"
@@ -47,24 +47,24 @@ typedef enum {
struct cherokee_downloader {
- cherokee_header_t *header;
- cherokee_request_header_t request;
+ cherokee_header_t *header;
+ cherokee_client_request_header_t request;
- cherokee_buffer_t request_header;
- cherokee_buffer_t reply_header;
- cherokee_buffer_t body;
+ cherokee_buffer_t request_header;
+ cherokee_buffer_t reply_header;
+ cherokee_buffer_t body;
- cherokee_buffer_t post;
- cherokee_buffer_t proxy;
- cuint_t proxy_port;
+ cherokee_buffer_t post;
+ cherokee_buffer_t proxy;
+ cuint_t proxy_port;
- cherokee_socket_t socket;
- cherokee_sockaddr_t sockaddr;
+ cherokee_socket_t socket;
+ cherokee_sockaddr_t sockaddr;
- cherokee_downloader_phase_t phase;
- cherokee_downloader_status_t status;
+ cherokee_downloader_phase_t phase;
+ cherokee_downloader_status_t status;
- cuint_t content_length;
+ cuint_t content_length;
/* Information
*/
@@ -75,8 +75,8 @@ struct cherokee_downloader {
uint32_t body_recv;
} info;
- cherokee_buffer_t tmp1;
- cherokee_buffer_t tmp2;
+ cherokee_buffer_t tmp1;
+ cherokee_buffer_t tmp2;
};
View
@@ -25,7 +25,7 @@
#include "common-internal.h"
#include "downloader.h"
#include "downloader-protected.h"
-#include "request.h"
+#include "client_request.h"
#include "url.h"
#include "header-protected.h"
#include "util.h"
@@ -53,7 +53,7 @@ cherokee_downloader_init (cherokee_downloader_t *n)
/* Build
*/
- ret = cherokee_request_header_init (&n->request);
+ ret = cherokee_client_request_header_init (&n->request);
if (unlikely(ret != ret_ok)) return ret;
ret = cherokee_buffer_init (&n->request_header);
@@ -104,7 +104,7 @@ cherokee_downloader_mrproper (cherokee_downloader_t *downloader)
{
/* Free the memory
*/
- cherokee_request_header_mrproper (&downloader->request);
+ cherokee_client_request_header_mrproper (&downloader->request);
cherokee_buffer_mrproper (&downloader->request_header);
cherokee_buffer_mrproper (&downloader->reply_header);
@@ -131,7 +131,7 @@ CHEROKEE_ADD_FUNC_FREE (downloader);
ret_t
cherokee_downloader_set_url (cherokee_downloader_t *downloader, cherokee_buffer_t *url_string)
{
- return cherokee_request_header_parse_string (&downloader->request, url_string);
+ return cherokee_client_request_header_parse_string (&downloader->request, url_string);
}
@@ -173,7 +173,7 @@ cherokee_downloader_set_auth (cherokee_downloader_t *downloader,
cherokee_buffer_t *user,
cherokee_buffer_t *password)
{
- return cherokee_request_header_set_auth (&downloader->request, http_auth_basic, user, password);
+ return cherokee_client_request_header_set_auth (&downloader->request, http_auth_basic, user, password);
}
@@ -267,7 +267,7 @@ cherokee_downloader_connect (cherokee_downloader_t *downloader)
/* Does it use a proxy?
*/
uses_proxy = ! cherokee_buffer_is_empty (&downloader->proxy);
- ret = cherokee_request_header_uses_proxy (&downloader->request, uses_proxy);
+ ret = cherokee_client_request_header_uses_proxy (&downloader->request, uses_proxy);
if (ret != ret_ok) return ret;
/* Connect
@@ -466,7 +466,7 @@ cherokee_downloader_step (cherokee_downloader_t *downloader,
*/
switch (downloader->phase) {
case downloader_phase_init: {
- cherokee_request_header_t *req = &downloader->request;
+ cherokee_client_request_header_t *req = &downloader->request;
TRACE(ENTRIES, "Phase %s\n", "init");
@@ -479,7 +479,7 @@ cherokee_downloader_step (cherokee_downloader_t *downloader,
/* Build the request header
*/
- ret = cherokee_request_header_build_string (req, &downloader->request_header, tmp1, tmp2);
+ ret = cherokee_client_request_header_build_string (req, &downloader->request_header, tmp1, tmp2);
if (unlikely(ret < ret_ok))
return ret;
@@ -604,7 +604,7 @@ cherokee_downloader_reuse (cherokee_downloader_t *downloader)
cherokee_buffer_clean (&downloader->body);
cherokee_buffer_clean (&downloader->post);
- cherokee_request_header_clean (&downloader->request);
+ cherokee_client_request_header_clean (&downloader->request);
return ret_ok;
}
View
@@ -1,226 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/* Cherokee
- *
- * Authors:
- * Alvaro Lopez Ortega <alvaro@alobbs.com>
- *
- * Copyright (C) 2001-2011 Alvaro Lopez Ortega
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#include "common-internal.h"
-#include "request.h"
-
-ret_t
-cherokee_request_header_init (cherokee_request_header_t *request)
-{
- ret_t ret;
-
- /* Init the node list information
- */
- INIT_LIST_HEAD (LIST(&request->list_node));
-
- /* Set default values
- */
- request->method = http_get;
- request->version = http_version_11;
- request->auth = http_auth_nothing;
- request->proxy = false;
- request->keepalive = true;
- request->pipeline = 1;
- request->post_len = 0;
-
- ret = cherokee_url_init (&request->url);
- if (unlikely(ret < ret_ok)) return ret;
-
- cherokee_buffer_init (&request->extra_headers);
- cherokee_buffer_init (&request->user);
- cherokee_buffer_init (&request->password);
-
- return ret_ok;
-}
-
-
-ret_t
-cherokee_request_header_mrproper (cherokee_request_header_t *request)
-{
- cherokee_buffer_mrproper (&request->user);
- cherokee_buffer_mrproper (&request->password);
- cherokee_buffer_mrproper (&request->extra_headers);
-
- cherokee_url_mrproper (&request->url);
- return ret_ok;
-}
-
-
-ret_t
-cherokee_request_header_clean (cherokee_request_header_t *request)
-{
- request->method = http_get;
- request->version = http_version_11;
- request->keepalive = true;
- request->pipeline = 1;
- request->post_len = 0;
-
- cherokee_url_clean (&request->url);
-
- return ret_ok;
-}
-
-ret_t
-cherokee_request_header_uses_proxy (cherokee_request_header_t *request, cherokee_boolean_t proxy)
-{
- request->proxy = proxy;
- return ret_ok;
-}
-
-
-ret_t
-cherokee_request_header_parse_string (cherokee_request_header_t *request, cherokee_buffer_t *url_string)
-{
- return cherokee_url_parse (&request->url, url_string, &request->user, &request->password);
-}
-
-
-ret_t
-cherokee_request_header_build_string (cherokee_request_header_t *request, cherokee_buffer_t *buf, cherokee_buffer_t *tmp1, cherokee_buffer_t *tmp2)
-{
- ret_t ret;
- const char *ptr;
- cuint_t len;
- cherokee_url_t *url = REQUEST_URL(request);
-
- /* 200 bytes should be enough for a small header
- */
- cherokee_buffer_ensure_size (buf, 200);
-
- /* Add main request line:
- * GET /dir/object HTTP/1.1
- */
- ret = cherokee_http_method_to_string (request->method, &ptr, &len);
- if (ret != ret_ok) return ret;
-
- ret = cherokee_buffer_add (buf, ptr, len);
- if (ret != ret_ok) return ret;
-
- cherokee_buffer_add_str (buf, " ");
-
- /* Check if the requests goes through a proxy
- */
- if (request->proxy) {
- cherokee_buffer_add_str (buf, "http://");
- cherokee_buffer_add_buffer (buf, URL_HOST(url));
- }
-
- cherokee_buffer_add_buffer (buf, URL_REQUEST(url));
-
- switch (REQUEST_VERSION(request)) {
- case http_version_11:
- cherokee_buffer_add_str (buf, " HTTP/1.1" CRLF);
- break;
- case http_version_10:
- cherokee_buffer_add_str (buf, " HTTP/1.0" CRLF);
- break;
- default:
- SHOULDNT_HAPPEN;
- return ret_error;
- }
-
- /* Add "Host:" header - in HTTP/1.1
- */
- if (REQUEST_VERSION(request) == http_version_11) {
- cherokee_buffer_add_str (buf, "Host: ");
- cherokee_buffer_add_buffer (buf, URL_HOST(url));
- cherokee_buffer_add_str (buf, CRLF);
- }
-
- /* Post information
- */
- if (request->post_len != 0) {
- /* "Content-Length: " FMT_OFFSET CRLF, request->post_len;
- */
- cherokee_buffer_add_str (buf, "Content-Length: ");
- cherokee_buffer_add_ullong10 (buf, (cullong_t) request->post_len);
- cherokee_buffer_add_str (buf, CRLF);
- }
-
- /* Add "Connection:" header
- */
- if (REQUEST_KEEPALIVE(request)) {
- cherokee_buffer_add_str (buf, "Connection: Keep-Alive"CRLF);
- } else {
- cherokee_buffer_add_str (buf, "Connection: close"CRLF);
- }
-
- /* Authentication
- */
- if (! cherokee_buffer_is_empty (&request->user) ||
- ! cherokee_buffer_is_empty (&request->password)) {
- cherokee_buffer_clean (tmp1);
- cherokee_buffer_clean (tmp2);
-
- cherokee_buffer_add_buffer (tmp1, &request->user);
- cherokee_buffer_add_char (tmp1, ':');
- cherokee_buffer_add_buffer (tmp1, &request->password);
-
- cherokee_buffer_encode_base64 (tmp1, tmp2);
-
- cherokee_buffer_add_str (buf, "Authorization: Basic ");
- cherokee_buffer_add_buffer (buf, tmp2);
- cherokee_buffer_add_str (buf, CRLF);
- }
-
- /* Extra headers
- */
- if (! cherokee_buffer_is_empty (&request->extra_headers)) {
- cherokee_buffer_add_buffer (buf, &request->extra_headers);
- }
-
- /* Finish the header
- */
- cherokee_buffer_add_str (buf, CRLF);
- return ret_ok;
-}
-
-
-ret_t
-cherokee_request_header_set_auth (cherokee_request_header_t *request,
- cherokee_http_auth_t auth,
- cherokee_buffer_t *user,
- cherokee_buffer_t *password)
-{
- request->auth = auth;
-
- cherokee_buffer_clean (&request->user);
- cherokee_buffer_clean (&request->password);
-
- cherokee_buffer_add_buffer (&request->user, user);
- cherokee_buffer_add_buffer (&request->password, password);
-
- return ret_ok;
-}
-
-
-ret_t
-cherokee_request_header_add_header (cherokee_request_header_t *request, char *ptr, cuint_t len)
-{
- cherokee_buffer_ensure_addlen (&request->extra_headers, len + CSZLEN(CRLF));
- cherokee_buffer_add (&request->extra_headers, ptr, len);
- cherokee_buffer_add_str (&request->extra_headers, CRLF);
-
- return ret_ok;
-}
Oops, something went wrong.

0 comments on commit 83ce154

Please sign in to comment.