1999-01-16 20:26:09 +00:00
|
|
|
/* http.h - HTTP protocol handler
|
2004-09-10 21:17:32 +00:00
|
|
|
* Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
|
1999-01-16 20:26:09 +00:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
2003-12-28 15:57:06 +00:00
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
#ifndef G10_HTTP_H
|
|
|
|
#define G10_HTTP_H 1
|
1999-01-16 20:26:09 +00:00
|
|
|
|
|
|
|
#include "iobuf.h"
|
|
|
|
|
|
|
|
struct uri_tuple {
|
|
|
|
struct uri_tuple *next;
|
|
|
|
const char *name; /* a pointer into name */
|
|
|
|
char *value; /* a pointer to value (a Nul is always appended) */
|
|
|
|
size_t valuelen; /* and the real length of the value */
|
|
|
|
/* because the value may contain embedded Nuls */
|
|
|
|
};
|
|
|
|
typedef struct uri_tuple *URI_TUPLE;
|
|
|
|
|
|
|
|
struct parsed_uri {
|
|
|
|
/* all these pointers point into buffer; most stuff is not escaped */
|
|
|
|
char *scheme; /* pointer to the scheme string (lowercase) */
|
2004-09-10 21:17:32 +00:00
|
|
|
char *auth; /* username/password for basic auth */
|
1999-01-16 20:26:09 +00:00
|
|
|
char *host; /* host (converted to lowercase) */
|
|
|
|
ushort port; /* port (always set if the host is set) */
|
|
|
|
char *path; /* the path */
|
|
|
|
URI_TUPLE params; /* ";xxxxx" */
|
|
|
|
URI_TUPLE query; /* "?xxx=yyy" */
|
|
|
|
char buffer[1]; /* buffer which holds a (modified) copy of the URI */
|
|
|
|
};
|
|
|
|
typedef struct parsed_uri *PARSED_URI;
|
|
|
|
|
1999-01-19 18:37:41 +00:00
|
|
|
typedef enum {
|
|
|
|
HTTP_REQ_GET = 1,
|
|
|
|
HTTP_REQ_HEAD = 2,
|
|
|
|
HTTP_REQ_POST = 3
|
|
|
|
} HTTP_REQ_TYPE;
|
|
|
|
|
2003-12-28 15:57:06 +00:00
|
|
|
/* put flag values into an enum, so that gdb can display them */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HTTP_FLAG_NO_SHUTDOWN = 1,
|
|
|
|
HTTP_FLAG_TRY_SRV = 2
|
|
|
|
};
|
2000-07-14 17:34:53 +00:00
|
|
|
|
1999-01-16 20:26:09 +00:00
|
|
|
struct http_context {
|
|
|
|
int initialized;
|
|
|
|
unsigned int status_code;
|
1999-02-16 13:16:33 +00:00
|
|
|
int sock;
|
1999-01-19 18:37:41 +00:00
|
|
|
int in_data;
|
1999-01-16 20:26:09 +00:00
|
|
|
IOBUF fp_read;
|
|
|
|
IOBUF fp_write;
|
|
|
|
int is_http_0_9;
|
|
|
|
PARSED_URI uri;
|
1999-01-19 18:37:41 +00:00
|
|
|
HTTP_REQ_TYPE req_type;
|
1999-01-16 20:26:09 +00:00
|
|
|
byte *buffer; /* line buffer */
|
2002-06-29 13:31:13 +00:00
|
|
|
unsigned buffer_size;
|
2000-07-14 17:34:53 +00:00
|
|
|
unsigned int flags;
|
1999-01-16 20:26:09 +00:00
|
|
|
};
|
|
|
|
typedef struct http_context *HTTP_HD;
|
|
|
|
|
1999-01-19 18:37:41 +00:00
|
|
|
int http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
|
2003-12-28 15:57:06 +00:00
|
|
|
unsigned int flags, const char *proxy );
|
1999-01-19 18:37:41 +00:00
|
|
|
void http_start_data( HTTP_HD hd );
|
|
|
|
int http_wait_response( HTTP_HD hd, unsigned int *ret_status );
|
|
|
|
void http_close( HTTP_HD hd );
|
2003-12-28 15:57:06 +00:00
|
|
|
int http_open_document( HTTP_HD hd, const char *document,
|
|
|
|
unsigned int flags, const char *proxy );
|
1999-01-16 20:26:09 +00:00
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
#endif /*G10_HTTP_H*/
|