1 /*
2    HTTP Request Handling
3    Copyright (C) 1999-2004, Joe Orton <joe@manyfish.co.uk>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public
16    License along with this library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18    MA 02111-1307, USA
19 
20 */
21 
22 /* THIS IS NOT A PUBLIC INTERFACE. You CANNOT include this header file
23  * from an application.  */
24 
25 #ifndef NE_PRIVATE_H
26 #define NE_PRIVATE_H
27 
28 #include "ne_request.h"
29 #include "ne_socket.h"
30 #include "ne_ssl.h"
31 
32 struct host_info {
33     char *hostname;
34     unsigned int port;
35     ne_sock_addr *address; /* if non-NULL, result of resolving 'hostname'. */
36     /* current network address obtained from 'address' being used. */
37     const ne_inet_addr *current;
38     char *hostport; /* URI hostport segment */
39 };
40 
41 /* Store every registered callback in a generic container, and cast
42  * the function pointer when calling it.  */
43 struct hook {
44     void (*fn)(void);
45     void *userdata;
46     const char *id; /* non-NULL for accessors. */
47     struct hook *next;
48 };
49 
50 #define HAVE_HOOK(st,func) (st->hook->hooks->func != NULL)
51 #define HOOK_FUNC(st, func) (*st->hook->hooks->func)
52 
53 /* Session support. */
54 struct ne_session_s {
55     /* Connection information */
56     ne_socket *socket;
57 
58     /* non-zero if connection has been established. */
59     int connected;
60 
61     /* non-zero if connection has persisted beyond one request. */
62     int persisted;
63 
64     int is_http11; /* >0 if connected server is known to be
65 		    * HTTP/1.1 compliant. */
66 
67     char *scheme;
68     struct host_info server, proxy;
69 
70     /* Settings */
71     unsigned int use_proxy:1; /* do we have a proxy server? */
72     unsigned int no_persist:1; /* set to disable persistent connections */
73     unsigned int use_ssl:1; /* whether a secure connection is required */
74     unsigned int in_connect:1; /* doing a proxy CONNECT */
75 
76     int expect100_works; /* known state of 100-continue support */
77 
78     ne_progress progress_cb;
79     void *progress_ud;
80 
81     ne_notify_status notify_cb;
82     void *notify_ud;
83 
84     int rdtimeout; /* read timeout. */
85 
86     struct hook *create_req_hooks, *pre_send_hooks, *post_send_hooks;
87     struct hook *destroy_req_hooks, *destroy_sess_hooks, *private;
88 
89     char *user_agent; /* full User-Agent: header field */
90 
91 #ifdef NEON_SSL
92     ne_ssl_client_cert *client_cert;
93     ne_ssl_certificate *server_cert;
94     ne_ssl_context *ssl_context;
95 #endif
96 
97     /* Server cert verification callback: */
98     ne_ssl_verify_fn ssl_verify_fn;
99     void *ssl_verify_ud;
100     /* Client cert provider callback: */
101     ne_ssl_provide_fn ssl_provide_fn;
102     void *ssl_provide_ud;
103 
104     /* Error string */
105     char error[BUFSIZ];
106 };
107 
108 typedef int (*ne_push_fn)(void *userdata, const char *buf, size_t count);
109 
110 /* Pulls the request body for the given request, passing blocks to the
111  * given callback.
112  */
113 int ne_pull_request_body(ne_request *req, ne_push_fn fn, void *ud);
114 
115 /* Do the SSL negotiation. */
116 int ne_negotiate_ssl(ne_request *req);
117 
118 /* 0.24.x hack to fix ne_compress layer problems */
119 void ne_kill_pre_send(ne_session *sess, ne_pre_send_fn fn, void *userdata);
120 
121 #endif /* HTTP_PRIVATE_H */
122