libtools
Classes | Macros | Typedefs | Enumerations | Functions
http.h File Reference

Copyright (C) 2016 Oleh Kravchenko oleg@.nosp@m.kaa..nosp@m.org.u.nosp@m.a More...

#include <stddef.h>
Include dependency graph for http.h:

Go to the source code of this file.

Classes

struct  http_header
 HTTP header type. More...
 

Macros

#define HTTP_HEADER_STRING(n, v)    { .type = HTTP_HEADER_STRING, .name = (n), .val.s = (v), }
 define HTTP header name with string value More...
 
#define HTTP_HEADER_INT(n, v)    { .type = HTTP_HEADER_INT, .name = (n), .val.i = (v), }
 define HTTP header name with integer value More...
 
#define HTTP_ERROR(x)   ((x) != HTTP_SUCCESS)
 return true if HTTP error occurred More...
 

Typedefs

typedef enum http_method http_method_t
 HTTP methods, see rfc2616. More...
 
typedef enum http_status http_status_t
 HTTP status code. More...
 
typedef enum http_header_type http_header_type_t
 HTTP header values type. More...
 
typedef struct http_header http_header_t
 HTTP header type. More...
 
typedef int(* http_request_cb_t) (http_method_t m, const char *path, const char *ver, void *priv)
 pointer to a callback function to process request More...
 
typedef int(* http_reply_cb_t) (const char *ver, int code, const char *msg, void *priv)
 pointer to a callback function to process reply More...
 
typedef int(* http_header_cb_t) (const char *name, const char *value, void *priv)
 pointer to a callback function to process header More...
 

Enumerations

enum  http_method {
  HTTP_OPTIONS, HTTP_GET, HTTP_HEAD, HTTP_POST,
  HTTP_PUT, HTTP_DELETE, HTTP_TRACE, HTTP_CONNECT
}
 HTTP methods, see rfc2616. More...
 
enum  http_status {
  HTTP_SUCCESS = 0, HTTP_CONNECTION_CLOSED, HTTP_SOCKET_ERROR, HTTP_LARGE_REQUEST,
  HTTP_INVALID_REQUEST, HTTP_UNKNOWN_REQUEST, HTTP_INVALID_HEADER, HTTP_INVALID_REPLY,
  HTTP_ABORTED, HTTP_OUT_MEMORY
}
 HTTP status code. More...
 
enum  http_header_type { HTTP_HEADER_STRING, HTTP_HEADER_INT }
 HTTP header values type. More...
 

Functions

http_status_t http_request_send (int sockfd, http_method_t method, const char *path, const char *ver, http_header_t hdr[], size_t count)
 send HTTP request by socket More...
 
http_status_t http_request_recv (int sockfd, http_request_cb_t request_cb, http_header_cb_t header_cb, void *priv)
 read HTTP request from socket and parse it More...
 
http_status_t http_reply_send (int sockfd, const char *ver, int code, const char *desc, http_header_t hdr[], size_t count)
 send HTTP reply to socket More...
 
http_status_t http_reply_recv (int sockfd, http_reply_cb_t reply_cb, http_header_cb_t header_cb, void *priv)
 read HTTP reply from socket and parse it More...
 

Detailed Description

Copyright (C) 2016 Oleh Kravchenko oleg@.nosp@m.kaa..nosp@m.org.u.nosp@m.a

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

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, see http://www.gnu.org/licenses/.