2 * Copyright 2018 Eduardo Chappa
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Last Edited: July 23, 2018 Eduardo Chappa <chappa@washington.edu>
14 typedef struct http_val_param_s
{
19 typedef struct http_param_list_s
{
21 struct http_param_list_s
*next
;
24 typedef struct http_header_value_s
{
29 typedef struct http_header_data_s
{
30 HTTP_HEADER_S
*accept
, /* RFC 7231, Section 5.3.2 */
31 *accept_charset
, /* RFC 7231, Section 5.3.3 */
32 *accept_encoding
, /* RFC 7231, Section 5.3.4 */
33 *accept_language
, /* RFC 7231, Section 5.3.5 */
34 *accept_ranges
, /* RFC 7233, Section 2.3 */
35 *age
, /* RFC 7234, Section 5.1 */
36 *allow
, /* RFC 7231, Section 7.4.1 */
37 *cache_control
, /* RFC 7234, Section 5.2 */
38 *connection
, /* RFC 7230, Section 6.1 */
39 *content_disposition
, /* RFC 6266 */
40 *content_encoding
, /* RFC 7231, Section 3.1.2.2 */
41 *content_language
, /* RFC 7231, Section 3.1.3.2 */
42 *content_length
, /* RFC 7230, Section 3.3.2 */
43 *content_location
, /* RFC 7231, Section 3.1.4.2 */
44 *content_type
, /* RFC 7231, Section 3.1.1.5 */
45 *date
, /* RFC 7231, Section 7.1.1.2 */
46 *etag
, /* RFC 7232, Section 2.3 */
47 *expect
, /* RFC 7231, Section 5.1.1 */
48 *expires
, /* RFC 7234, Section 5.3 */
49 *from
, /* RFC 7231, Section 5.5.1 */
50 *host
, /* RFC 7230, Section 5.4 */
51 *last_modified
, /* RFC 7232, Section 2.2 */
52 *location
, /* RFC 7231, Section 7.1.2 */
53 *max_forwards
, /* RFC 7231, Section 5.1.2 */
54 *mime_version
, /* RFC 7231, Appendix A.1 */
55 *pragma
, /* RFC 7234, Section 5.4 */
56 *proxy_authenticate
, /* RFC 7235, Section 4.3 */
57 *referer
, /* RFC 7231, Section 5.5.2 */
58 *retry_after
, /* RFC 7231, Section 7.1.3 */
59 *server
, /* RFC 7231, Section 7.4.2 */
60 *user_agent
, /* RFC 7231, Section 5.5.3 */
61 *te
, /* RFC 7230, Section 4.3 */
62 *trailer
, /* RFC 7230, Section 4.4 */
63 *transfer_encoding
, /* RFC 7230, Section 3.3.1 */
64 *upgrade
, /* RFC 7230, Section 6.7 */
65 *via
, /* RFC 7230, Section 5.7.1 */
66 *vary
, /* RFC 7231, Section 7.1.4 */
67 *warning
, /* RFC 7234, Section 5.5 */
68 *www_authenticate
; /* RFC 7235, Section 4.1 */
71 #define HTTP_MIME_URLENCODED "application/x-www-form-urlencoded"
73 #define HTTP_1_1_VERSION "HTTP/1.1"
77 #define GET_HTTPPORT (long) 490
78 #define SET_HTTPPORT (long) 491
79 #define GET_SSLHTTPPORT (long) 492
80 #define SET_SSLHTTPPORT (long) 493
82 typedef struct http_status_s
{
89 typedef struct http_stream
{
91 HTTP_HEADER_DATA_S
*header
; /* headers sent by the server */
92 char *url
; /* original url */
93 char *urlhost
; /* get original host */
94 char *urltail
; /* the part of the URL after the original host */
95 HTTP_STATUS_S
*status
;/* parsed status line from server */
96 unsigned char *response
; /* last reply line from server */
97 unsigned char *reply
; /* the full reply from the server */
100 /* parameters for a get or post call */
101 typedef struct http_param_s
{
106 /* exported prototypes */
107 HTTPSTREAM
*http_open (unsigned char *);
108 unsigned char *http_post_param(unsigned char *, HTTP_PARAM_S
*, int *);
109 unsigned char *http_post_param2(unsigned char *, HTTP_PARAM_S
*, int *);
110 unsigned char *http_get_param(unsigned char *, HTTP_PARAM_S
*, int *);
111 unsigned char *http_get(unsigned char *, int *);
112 void http_close (HTTPSTREAM
*stream
);
114 HTTP_PARAM_S
*http_param_get(int);
115 void http_param_free(HTTP_PARAM_S
**);
117 /* Ugghh.... just construct the URL for a get request */
118 unsigned char *http_get_param_url(unsigned char *, HTTP_PARAM_S
*);