pazpar2  1.14.1
http.h
Go to the documentation of this file.
1 /* This file is part of Pazpar2.
2  Copyright (C) Index Data
3 
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #ifndef HTTP_H
21 #define HTTP_H
22 
23 #include <yaz/wrbuf.h>
24 #include <yaz/timing.h>
25 
26 #include "eventl.h"
27 // Generic I/O buffer
28 struct http_buf;
30 
31 typedef struct http_server *http_server_t;
33 
35 {
37  struct http_buf *iqueue;
38  struct http_buf *oqueue;
39  char version[10];
40  struct http_proxy *proxy;
41  enum
42  {
44  Http_Busy // Don't process new HTTP requests while we're busy
45  } state;
47  NMEM nmem;
48  WRBUF wrbuf;
49  yaz_timing_t yt;
52  struct http_channel *next; // for freelist
53  char addr[256]; // forwarded address
58 };
59 
60 struct http_proxy // attached to iochan for proxy connection
61 {
64  struct http_buf *oqueue;
66 };
67 
69 {
70  char *name;
71  char *value;
72  struct http_header *next;
73 };
74 
76 {
77  char *name;
78  char *value;
80 };
81 
83 {
85  char http_version[20];
86  char method[20];
87  char *path;
88  char *search;
89  char *content_buf;
93 };
94 
96 {
97  char code[4];
98  char *msg;
101  char *payload;
103 };
104 
105 void http_mutex_init(struct conf_server *server);
107 
108 void http_set_proxyaddr(const char *url, struct conf_server *ser);
109 int http_init(struct conf_server *ser, const char *record_fname);
110 void http_close_server(struct conf_server *ser);
111 void http_addheader(struct http_response *r,
112  const char *name, const char *value);
113 const char *http_lookup_header(struct http_header *header,
114  const char *name);
115 struct http_header * http_header_append(struct http_channel *ch,
116  struct http_header * hp,
117  const char *name,
118  const char *value);
119 const char *http_argbyname(struct http_request *r, const char *name);
120 const char *http_headerbyname(struct http_header *r, const char *name);
122 void http_send_response(struct http_channel *c);
123 void urlencode(const char *i, char *o);
124 
125 typedef void (*http_channel_destroy_t)(void *data, struct http_channel *c,
126  void *data2);
127 
130 void http_observer_set_data2(http_channel_observer_t obs, void *data2);
131 
134 
135 void http_command(struct http_channel *c);
136 
139 
140 #endif
141 
142 /*
143  * Local variables:
144  * c-basic-offset: 4
145  * c-file-style: "Stroustrup"
146  * indent-tabs-mode: nil
147  * End:
148  * vim: shiftwidth=4 tabstop=8 expandtab
149  */
150 
http_channel_observer_t http_add_observer(struct http_channel *c, void *data, http_channel_destroy_t)
Definition: http.c:1430
void http_set_proxyaddr(const char *url, struct conf_server *ser)
Definition: http.c:1375
struct http_response * http_create_response(struct http_channel *c)
Definition: http.c:311
void(* http_channel_destroy_t)(void *data, struct http_channel *c, void *data2)
Definition: http.h:125
http_sessions_t http_sessions_create(void)
Definition: http_command.c:98
const char * http_lookup_header(struct http_header *header, const char *name)
Definition: http.c:119
void http_remove_observer(http_channel_observer_t obs)
Definition: http.c:1443
void http_close_server(struct conf_server *ser)
Definition: http.c:1362
struct http_channel_observer_s * http_channel_observer_t
Definition: http.h:29
void http_send_response(struct http_channel *c)
Definition: http.c:844
void http_sessions_destroy(http_sessions_t hs)
Definition: http_command.c:108
struct http_header * http_header_append(struct http_channel *ch, struct http_header *hp, const char *name, const char *value)
Definition: http.c:702
struct http_sessions * http_sessions_t
Definition: http.h:32
void http_command(struct http_channel *c)
void urlencode(const char *i, char *o)
Definition: http.c:266
const char * http_headerbyname(struct http_header *r, const char *name)
Definition: http.c:303
const char * http_argbyname(struct http_request *r, const char *name)
Definition: http.c:292
void http_addheader(struct http_response *r, const char *name, const char *value)
Definition: http.c:282
void http_observer_set_data2(http_channel_observer_t obs, void *data2)
Definition: http.c:1460
int http_init(struct conf_server *ser, const char *record_fname)
Definition: http.c:1238
struct http_channel * http_channel_observer_chan(http_channel_observer_t obs)
Definition: http.c:1455
void http_mutex_init(struct conf_server *server)
Definition: http.c:1509
void http_server_destroy(http_server_t hs)
Definition: http.c:1479
struct http_server * http_server_t
Definition: http.h:31
char * name
char * value
Definition: http.h:78
struct http_argument * next
Definition: http.h:79
char * name
Definition: http.h:77
Definition: http.c:76
struct http_request * request
Definition: http.h:50
@ Http_Idle
Definition: http.h:43
@ Http_Busy
Definition: http.h:44
NMEM nmem
Definition: http.h:47
http_sessions_t http_sessions
Definition: http.h:57
IOCHAN iochan
Definition: http.h:36
struct http_response * response
Definition: http.h:51
struct http_channel * next
Definition: http.h:52
int keep_alive
Definition: http.h:46
struct http_buf * oqueue
Definition: http.h:38
yaz_timing_t yt
Definition: http.h:49
http_channel_observer_t observers
Definition: http.h:54
struct http_proxy * proxy
Definition: http.h:40
struct http_buf * iqueue
Definition: http.h:37
http_server_t http_server
Definition: http.h:56
char version[10]
Definition: http.h:39
char addr[256]
Definition: http.h:53
enum http_channel::@1 state
WRBUF wrbuf
Definition: http.h:48
struct conf_server * server
Definition: http.h:55
char * name
Definition: http.h:70
char * value
Definition: http.h:71
struct http_header * next
Definition: http.h:72
struct http_channel * channel
Definition: http.h:63
struct http_buf * oqueue
Definition: http.h:64
int first_response
Definition: http.h:65
IOCHAN iochan
Definition: http.h:62
char http_version[20]
Definition: http.h:85
struct http_header * headers
Definition: http.h:91
char * search
Definition: http.h:88
int content_len
Definition: http.h:90
struct http_argument * arguments
Definition: http.h:92
char * path
Definition: http.h:87
char method[20]
Definition: http.h:86
char * content_buf
Definition: http.h:89
struct http_channel * channel
Definition: http.h:84
struct http_header * headers
Definition: http.h:100
struct http_channel * channel
Definition: http.h:99
char code[4]
Definition: http.h:97
char * content_type
Definition: http.h:102
char * payload
Definition: http.h:101
char * msg
Definition: http.h:98
Definition: eventl.h:32