Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / nsapi-includes / frame / http.h
blob7136daf0854f30c7e48b54dd721aa1598c7f2261
1 /*
2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
3 * rights reserved.
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
7 * parties.
8 */
11 /* ------------------------------------------------------------------------ */
15 * http.h: Deals with HTTP-related issues
17 * Rob McCool
21 #ifndef HTTP_H
22 #define HTTP_H
25 #include "netsite.h"
26 #include "base/session.h"
27 #include "base/pblock.h"
29 #include "frame/req.h" /* REQ_MAX_LINE, Request structure */
31 /* ------------------------------ Constants ------------------------------- */
34 #define HTTP_DATE_LEN 128
35 #define HTTP_DATE_FMT "%A, %d-%b-%y %T GMT"
38 /* The maximum number of RFC-822 headers we'll allow */
39 /* This would be smaller if a certain browser wasn't so damn stupid. */
40 #define HTTP_MAX_HEADERS 200
42 /* Whether or not we should read the headers for if-modified-since */
43 #define HTTP_DO_IMS
44 #define HTTP_ALWAYS_LOADHDRS
46 /* HTTP status codes */
48 #define PROTOCOL_OK 200
49 #define PROTOCOL_NO_RESPONSE 204
50 #define PROTOCOL_REDIRECT 302
51 #define PROTOCOL_NOT_MODIFIED 304
52 #define PROTOCOL_BAD_REQUEST 400
53 #define PROTOCOL_UNAUTHORIZED 401
54 #define PROTOCOL_FORBIDDEN 403
55 #define PROTOCOL_NOT_FOUND 404
56 #define PROTOCOL_PROXY_UNAUTHORIZED 407
57 #define PROTOCOL_SERVER_ERROR 500
58 #define PROTOCOL_NOT_IMPLEMENTED 501
61 #ifdef NET_SSL
62 #define HTTPS_PORT 443
63 #define HTTPS_URL "https"
64 #endif
65 #define HTTP_PORT 80
66 #define HTTP_URL "http"
68 /* -------------------------- http_scan_headers --------------------------- */
72 * parses the first line of an HTTP request
75 #define protocol_parse_request http_parse_request
76 int http_parse_request(char *t, Request *rq, Session *sn);
79 * Scans HTTP headers from the given netbuf, and places them in headers.
80 * If netbuf is NULL, the session's inbuf is used.
82 * Folded lines are joined and the linefeed removed (but not the whitespace).
83 * If there are any repeat headers they are joined and the two field bodies
84 * separated by a comma and space.
86 * t should be a string of length REQ_MAX_LINE. This is a convenience to
87 * req.c so that we don't use too much runtime stack.
89 * Session is an optional parameter. Use NULL if you wish. It's used for
90 * error logs.
93 #define protocol_scan_headers http_scan_headers
94 int http_scan_headers(Session *sn, netbuf *buf, char *t, pblock *headers);
98 * Starts the HTTP response. If HTTP/0.9, does nothing. If 1.0, sends header.
99 * If this returns REQ_NOACTION, the method was head and no body should be
100 * sent. Otherwise, it will return REQ_PROCEED.
103 #define protocol_start_response http_start_response
104 int http_start_response(Session *sn, Request *rq);
108 * http_hdrs2env takes the entries from the given pblock and converts them
109 * to an environment.
111 * Each name entry will be made uppercase, prefixed with HTTP_ and any
112 * occurrence of - will be converted to _.
115 char **http_hdrs2env(pblock *pb);
117 //FUZZ: disable check_for_NULL
119 * http_status sets status to the code n, with reason string r. If r is
120 * NULL, the server will attempt to find one for the given status code.
121 * If it finds none, it will give "Because I felt like it."
123 //FUZZ: enable check_for_NULL
125 #define protocol_status http_status
126 void http_status(Session *sn, Request *rq, int n, char *r);
129 * http_set_finfo sets content-length and last-modified
132 #define protocol_set_finfo http_set_finfo
133 int http_set_finfo(Session *sn, Request *rq, struct stat *finfo);
137 * Takes the given pblock and prints headers into the given buffer at
138 * position pos. Returns the buffer, reallocated if needed. Modifies pos.
141 char *http_dump822(pblock *pb, char *t, int *pos, int tsz);
144 * Finishes a request. For HTTP, this just closes the socket.
147 #define protocol_finish_request http_finish_request
148 void http_finish_request(Session *sn, Request *rq);
152 * http_handle_session processes each request generated by Session
155 #define protocol_handle_session http_handle_session
156 void http_handle_session(Session *sn);
159 * http_uri2url takes the give URI prefix and URI suffix and creates a
160 * newly-allocated full URL from them of the form
161 * http://(server):(port)(prefix)(suffix)
163 * If you want either prefix or suffix to be skipped, use "" instead of NULL.
166 #define protocol_uri2url http_uri2url
167 char *http_uri2url(char *prefix, char *suffix);
169 #endif