mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-22 19:58:29 +01:00
* http.c (send_request, http_open_document, http_open): Pass the http
proxy from outside rather than pulling it from the evironment.
This commit is contained in:
parent
4cf0123a68
commit
eea75c0234
@ -1,3 +1,9 @@
|
|||||||
|
2003-12-28 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* http.c (send_request, http_open_document, http_open): Pass the
|
||||||
|
http proxy from outside rather than pulling it from the
|
||||||
|
evironment.
|
||||||
|
|
||||||
2003-12-28 Stefan Bellon <sbellon@sbellon.de>
|
2003-12-28 Stefan Bellon <sbellon@sbellon.de>
|
||||||
|
|
||||||
* riscos.c [__riscos__]: Better filetype handling (use a
|
* riscos.c [__riscos__]: Better filetype handling (use a
|
||||||
|
45
util/http.c
45
util/http.c
@ -45,14 +45,6 @@
|
|||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "srv.h"
|
#include "srv.h"
|
||||||
|
|
||||||
#ifdef __riscos__
|
|
||||||
#define HTTP_PROXY_ENV "GnuPG$HttpProxy"
|
|
||||||
#define HTTP_PROXY_ENV_PRINTABLE "<GnuPG$HttpProxy>"
|
|
||||||
#else
|
|
||||||
#define HTTP_PROXY_ENV "http_proxy"
|
|
||||||
#define HTTP_PROXY_ENV_PRINTABLE "$http_proxy"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define sock_close(a) closesocket(a)
|
#define sock_close(a) closesocket(a)
|
||||||
#else
|
#else
|
||||||
@ -76,7 +68,7 @@ static int remove_escapes( byte *string );
|
|||||||
static int insert_escapes( byte *buffer, const byte *string,
|
static int insert_escapes( byte *buffer, const byte *string,
|
||||||
const byte *special );
|
const byte *special );
|
||||||
static URI_TUPLE parse_tuple( byte *string );
|
static URI_TUPLE parse_tuple( byte *string );
|
||||||
static int send_request( HTTP_HD hd );
|
static int send_request( HTTP_HD hd, const char *proxy );
|
||||||
static byte *build_rel_path( PARSED_URI uri );
|
static byte *build_rel_path( PARSED_URI uri );
|
||||||
static int parse_response( HTTP_HD hd );
|
static int parse_response( HTTP_HD hd );
|
||||||
|
|
||||||
@ -118,7 +110,7 @@ init_sockets (void)
|
|||||||
|
|
||||||
int
|
int
|
||||||
http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
|
http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
|
||||||
unsigned int flags )
|
unsigned int flags, const char *proxy )
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -134,7 +126,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
|
|||||||
|
|
||||||
rc = parse_uri( &hd->uri, url );
|
rc = parse_uri( &hd->uri, url );
|
||||||
if( !rc ) {
|
if( !rc ) {
|
||||||
rc = send_request( hd );
|
rc = send_request( hd, proxy );
|
||||||
if( !rc ) {
|
if( !rc ) {
|
||||||
hd->fp_write = iobuf_sockopen( hd->sock , "w" );
|
hd->fp_write = iobuf_sockopen( hd->sock , "w" );
|
||||||
if( hd->fp_write )
|
if( hd->fp_write )
|
||||||
@ -197,11 +189,12 @@ http_wait_response( HTTP_HD hd, unsigned int *ret_status )
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
http_open_document( HTTP_HD hd, const char *document, unsigned int flags )
|
http_open_document( HTTP_HD hd, const char *document,
|
||||||
|
unsigned int flags, const char *proxy )
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = http_open( hd, HTTP_REQ_GET, document, flags );
|
rc = http_open( hd, HTTP_REQ_GET, document, flags, proxy );
|
||||||
if( rc )
|
if( rc )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -213,8 +206,6 @@ http_open_document( HTTP_HD hd, const char *document, unsigned int flags )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
http_close( HTTP_HD hd )
|
http_close( HTTP_HD hd )
|
||||||
{
|
{
|
||||||
@ -430,9 +421,6 @@ insert_escapes( byte *buffer, const byte *string, const byte *special )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static URI_TUPLE
|
static URI_TUPLE
|
||||||
parse_tuple( byte *string )
|
parse_tuple( byte *string )
|
||||||
{
|
{
|
||||||
@ -471,32 +459,31 @@ parse_tuple( byte *string )
|
|||||||
* Returns 0 if the request was successful
|
* Returns 0 if the request was successful
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
send_request( HTTP_HD hd )
|
send_request( HTTP_HD hd, const char *proxy )
|
||||||
{
|
{
|
||||||
const byte *server;
|
const byte *server;
|
||||||
byte *request, *p;
|
byte *request, *p;
|
||||||
ushort port;
|
ushort port;
|
||||||
int rc;
|
int rc;
|
||||||
const char *http_proxy = NULL;
|
|
||||||
|
|
||||||
server = *hd->uri->host? hd->uri->host : "localhost";
|
server = *hd->uri->host? hd->uri->host : "localhost";
|
||||||
port = hd->uri->port? hd->uri->port : 80;
|
port = hd->uri->port? hd->uri->port : 80;
|
||||||
|
|
||||||
if( (hd->flags & HTTP_FLAG_TRY_PROXY)
|
if(proxy)
|
||||||
&& (http_proxy = getenv( HTTP_PROXY_ENV )) ) {
|
{
|
||||||
PARSED_URI uri;
|
PARSED_URI uri;
|
||||||
|
|
||||||
rc = parse_uri( &uri, http_proxy );
|
rc = parse_uri( &uri, proxy );
|
||||||
if (rc) {
|
if (rc)
|
||||||
log_error("invalid " HTTP_PROXY_ENV_PRINTABLE ": %s\n",
|
{
|
||||||
g10_errstr(rc));
|
log_error("invalid HTTP proxy (%s): %s\n",proxy,g10_errstr(rc));
|
||||||
release_parsed_uri( uri );
|
release_parsed_uri( uri );
|
||||||
return G10ERR_NETWORK;
|
return G10ERR_NETWORK;
|
||||||
}
|
}
|
||||||
hd->sock = connect_server( *uri->host? uri->host : "localhost",
|
hd->sock = connect_server( *uri->host? uri->host : "localhost",
|
||||||
uri->port? uri->port : 80, 0 );
|
uri->port? uri->port : 80, 0 );
|
||||||
release_parsed_uri( uri );
|
release_parsed_uri( uri );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hd->sock = connect_server( server, port, hd->flags );
|
hd->sock = connect_server( server, port, hd->flags );
|
||||||
|
|
||||||
@ -505,7 +492,7 @@ send_request( HTTP_HD hd )
|
|||||||
|
|
||||||
p = build_rel_path( hd->uri );
|
p = build_rel_path( hd->uri );
|
||||||
request = m_alloc( strlen(server)*2 + strlen(p) + 50 );
|
request = m_alloc( strlen(server)*2 + strlen(p) + 50 );
|
||||||
if( http_proxy ) {
|
if( proxy ) {
|
||||||
sprintf( request, "%s http://%s:%hu%s%s HTTP/1.0\r\n",
|
sprintf( request, "%s http://%s:%hu%s%s HTTP/1.0\r\n",
|
||||||
hd->req_type == HTTP_REQ_GET ? "GET" :
|
hd->req_type == HTTP_REQ_GET ? "GET" :
|
||||||
hd->req_type == HTTP_REQ_HEAD? "HEAD":
|
hd->req_type == HTTP_REQ_HEAD? "HEAD":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user