http.h revision 0a44ef6d9afbfe052a7e975f55ea0d2954b62a82
/*
* "$Id: http.h 148 2006-04-25 16:54:17Z njacobs $"
*
* Hyper-Text Transport Protocol definitions for the Common UNIX Printing
* System (CUPS).
*
* Copyright 1997-2005 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
* copyright law. Distribution and use rights are outlined in the file
* "LICENSE.txt" which should have been included with this file. If this
* file is missing or damaged please contact Easy Software Products
* at:
*
* Attn: CUPS Licensing Information
* Easy Software Products
* 44141 Airport View Drive, Suite 204
* Hollywood, Maryland 20636 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_HTTP_H_
#define _CUPS_HTTP_H_
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Include necessary headers...
*/
# include <string.h>
# include <time.h>
# ifdef WIN32
# include <winsock.h>
# else
# include <unistd.h>
# include <netdb.h>
# include <netinet/in_systm.h>
# if !defined(__APPLE__) || !defined(TCP_NODELAY)
# endif /* !__APPLE__ || !TCP_NODELAY */
# ifdef AF_LOCAL
# endif /* AF_LOCAL */
# endif /* WIN32 */
/*
* C++ magic...
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Oh, the wonderful world of IPv6 compatibility. Apparently some
* implementations expose the (more logical) 32-bit address parts
* to everyone, while others only expose it to kernel code... To
* make supporting IPv6 even easier, each vendor chose different
* core structure and union names, so the same defines or code
* can't be used on all platforms.
*
* The following will likely need tweeking on new platforms that
* support IPv6 - the "s6_addr32" define maps to the 32-bit integer
* array in the in6_addr union, which is named differently on various
* platforms.
*/
# if defined(__sun)
# endif /* __sun */
#endif /* AF_INET6 && !s6_addr32 */
/*
* Limits...
*/
/*
* HTTP state values...
*/
typedef enum /* States are server-oriented */
{
HTTP_WAITING, /* Waiting for command */
HTTP_OPTIONS, /* OPTIONS command, waiting for blank line */
HTTP_GET, /* GET command, waiting for blank line */
HTTP_GET_SEND, /* GET command, sending data */
HTTP_HEAD, /* HEAD command, waiting for blank line */
HTTP_POST, /* POST command, waiting for blank line */
HTTP_POST_RECV, /* POST command, receiving data */
HTTP_POST_SEND, /* POST command, sending data */
HTTP_PUT, /* PUT command, waiting for blank line */
HTTP_PUT_RECV, /* PUT command, receiving data */
HTTP_DELETE, /* DELETE command, waiting for blank line */
HTTP_TRACE, /* TRACE command, waiting for blank line */
HTTP_CLOSE, /* CLOSE command, waiting for blank line */
HTTP_STATUS /* Command complete, sending status */
} http_state_t;
/*
* HTTP version numbers...
*/
typedef enum
{
/*
* HTTP keep-alive values...
*/
typedef enum
{
HTTP_KEEPALIVE_OFF = 0,
/*
* HTTP transfer encoding values...
*/
typedef enum
{
HTTP_ENCODE_LENGTH, /* Data is sent with Content-Length */
HTTP_ENCODE_CHUNKED /* Data is chunked */
/*
* HTTP encryption values...
*/
typedef enum
{
HTTP_ENCRYPT_IF_REQUESTED, /* Encrypt if requested (TLS upgrade) */
HTTP_ENCRYPT_NEVER, /* Never encrypt */
HTTP_ENCRYPT_REQUIRED, /* Encryption is required (TLS upgrade) */
HTTP_ENCRYPT_ALWAYS /* Always encrypt (SSL) */
/*
* HTTP authentication types...
*/
typedef enum
{
HTTP_AUTH_NONE, /* No authentication in use */
HTTP_AUTH_BASIC, /* Basic authentication in use */
HTTP_AUTH_MD5, /* Digest authentication in use */
HTTP_AUTH_MD5_SESS, /* MD5-session authentication in use */
HTTP_AUTH_MD5_INT, /* Digest authentication in use for body */
HTTP_AUTH_MD5_SESS_INT /* MD5-session authentication in use for body */
} http_auth_t;
/*
* HTTP status codes...
*/
typedef enum
{
HTTP_SWITCHING_PROTOCOLS, /* HTTP upgrade to TLS/SSL */
HTTP_CREATED, /* PUT command was successful */
HTTP_ACCEPTED, /* DELETE command was successful */
HTTP_NOT_AUTHORITATIVE, /* Information isn't authoritative */
HTTP_NO_CONTENT, /* Successful command, no new data */
HTTP_RESET_CONTENT, /* Content was reset/recreated */
HTTP_PARTIAL_CONTENT, /* Only a partial file was recieved/sent */
HTTP_MOVED_PERMANENTLY, /* Document has moved permanently */
HTTP_MOVED_TEMPORARILY, /* Document has moved temporarily */
HTTP_SEE_OTHER, /* See this other link... */
HTTP_NOT_MODIFIED, /* File not modified */
HTTP_USE_PROXY, /* Must use a proxy to access this URI */
HTTP_UNAUTHORIZED, /* Unauthorized to access host */
HTTP_PAYMENT_REQUIRED, /* Payment required */
HTTP_FORBIDDEN, /* Forbidden to access this URI */
HTTP_NOT_FOUND, /* URI was not found */
HTTP_METHOD_NOT_ALLOWED, /* Method is not allowed */
HTTP_NOT_ACCEPTABLE, /* Not Acceptable */
HTTP_PROXY_AUTHENTICATION, /* Proxy Authentication is Required */
HTTP_REQUEST_TIMEOUT, /* Request timed out */
HTTP_CONFLICT, /* Request is self-conflicting */
HTTP_GONE, /* Server has gone away */
HTTP_LENGTH_REQUIRED, /* A content length or encoding is required */
HTTP_PRECONDITION, /* Precondition failed */
HTTP_REQUEST_TOO_LARGE, /* Request entity too large */
HTTP_URI_TOO_LONG, /* URI too long */
HTTP_UNSUPPORTED_MEDIATYPE, /* The requested media type is unsupported */
HTTP_NOT_IMPLEMENTED, /* Feature not implemented */
HTTP_BAD_GATEWAY, /* Bad gateway */
HTTP_SERVICE_UNAVAILABLE, /* Service is unavailable */
HTTP_GATEWAY_TIMEOUT, /* Gateway connection timed out */
HTTP_NOT_SUPPORTED /* HTTP version not supported */
/*
* HTTP field names...
*/
typedef enum
{
HTTP_FIELD_UNKNOWN = -1,
} http_field_t;
/*
* HTTP address structure (makes using IPv6 a little easier and more portable.)
*/
typedef union
{
#ifdef AF_INET6
#endif /* AF_INET6 */
#ifdef AF_LOCAL
#endif /* AF_LOCAL */
} http_addr_t;
/*
* HTTP connection structure...
*/
typedef struct
{
int fd; /* File descriptor for this socket */
int blocking; /* To block or not to block */
int error; /* Last error on read */
char hostname[HTTP_MAX_HOST],
/* Name of connected host */
/* Field values */
char *data; /* Pointer to data buffer */
int data_remaining; /* Number of bytes left */
int used; /* Number of bytes used in buffer */
char buffer[HTTP_MAX_BUFFER];
/* Buffer for messages */
int auth_type; /* Authentication in use */
char nonce[HTTP_MAX_VALUE];
/* Nonce value */
int nonce_count; /* Nonce count */
void *tls; /* TLS state information */
/**** New in CUPS 1.1.19 ****/
char *cookie; /* Cookie value(s) */
/**** New in CUPS 1.1.20 ****/
char authstring[HTTP_MAX_VALUE],
/* Current Authentication value */
/* Username:password string */
int digest_tries; /* Number of tries for digest auth */
/**** New in CUPS 1.2 ****/
} http_t;
/*
* Prototypes...
*/
extern const char *httpGetDateString(time_t t);
extern time_t httpGetDateTime(const char *s);
extern void httpInitialize(void);
# ifdef __GNUC__
# endif /* __GNUC__ */
;
char *resource);
const char *value);
extern char *httpMD5(const char *, const char *, const char *,
char [33]);
extern char *httpMD5Final(const char *, const char *, const char *,
char [33]);
extern char *httpMD5String(const unsigned char *, char [33]);
/**** New in CUPS 1.1.19 ****/
/**** New in CUPS 1.1.21 ****/
int inlen);
extern void httpSeparate2(const char *uri,
char *username, int usernamelen,
char *resource, int resourcelen);
/**** New in CUPS 1.2 ****/
const http_addr_t *addr2);
int n, http_addr_t *addr);
char *s, int slen);
#include <stdio.h>
extern void httpDumpData(FILE *, const char *, const char *, int);
/*
* C++ magic...
*/
#ifdef __cplusplus
}
#endif
#endif /* !_CUPS_HTTP_H_ */
/*
* End of "$Id: http.h 148 2006-04-25 16:54:17Z njacobs $"
*/