[axel-commits] r47 - in /trunk: axel.1 axel.h conf.c conf.h conn.c http.c text.c
phihag-guest at users.alioth.debian.org
phihag-guest at users.alioth.debian.org
Mon Sep 15 12:52:45 UTC 2008
Author: phihag-guest
Date: Mon Sep 15 12:52:45 2008
New Revision: 47
URL: http://svn.debian.org/wsvn/axel/?sc=1&rev=47
Log:
+ Option to set the HTTP user agent (#311073)
+ Documentation for -H
Modified:
trunk/axel.1
trunk/axel.h
trunk/conf.c
trunk/conf.h
trunk/conn.c
trunk/http.c
trunk/text.c
Modified: trunk/axel.1
URL: http://svn.debian.org/wsvn/axel/trunk/axel.1?rev=47&op=diff
==============================================================================
--- trunk/axel.1 (original)
+++ trunk/axel.1 Mon Sep 15 12:52:45 2008
@@ -79,6 +79,18 @@
estimate for the remaining download time.
.TP
+\fB\-\-header=x\fP, \fB\-H\ x\fP
+Add an additional HTTP header. This option should be in the form "Header:
+Value". See RFC 2616 section 4.2 and 14 for details on the format and
+standardized headers.
+
+.TP
+\fB\-\-user-agent=x\fP, \fB\-U\ x\fP
+Set the HTTP user agent to use. Some websites serve different content based upon
+this parameter. The default value will include "Axel", its version and the
+platform.
+
+.TP
\fB\-\-help\fP, \fB\-h\fP
A brief summary of all the options.
Modified: trunk/axel.h
URL: http://svn.debian.org/wsvn/axel/trunk/axel.h?rev=47&op=diff
==============================================================================
--- trunk/axel.h (original)
+++ trunk/axel.h Mon Sep 15 12:52:45 2008
@@ -68,7 +68,7 @@
#define MAX_ADD_HEADERS 10
#define MAX_REDIR 5
#define AXEL_VERSION_STRING "2.1"
-#define USER_AGENT "Axel " AXEL_VERSION_STRING " (" ARCH ")"
+#define DEFAULT_USER_AGENT "Axel " AXEL_VERSION_STRING " (" ARCH ")"
typedef struct
{
Modified: trunk/conf.c
URL: http://svn.debian.org/wsvn/axel/trunk/conf.c?rev=47&op=diff
==============================================================================
--- trunk/conf.c (original)
+++ trunk/conf.c Mon Sep 15 12:52:45 2008
@@ -110,6 +110,7 @@
get_config_number( add_header_count );
for(i=0;i<conf->add_header_count;i++)
get_config_string( add_header[i] );
+ get_config_string( user_agent );
}
fclose( fp );
@@ -140,7 +141,8 @@
conf->search_threads = 3;
conf->search_amount = 15;
conf->search_top = 3;
- conf->add_header_count = 0;
+ conf->add_header_count = 0;
+ strncpy( conf->user_agent, DEFAULT_USER_AGENT, MAX_STRING );
conf->interfaces = malloc( sizeof( if_t ) );
memset( conf->interfaces, 0, sizeof( if_t ) );
Modified: trunk/conf.h
URL: http://svn.debian.org/wsvn/axel/trunk/conf.h?rev=47&op=diff
==============================================================================
--- trunk/conf.h (original)
+++ trunk/conf.h Mon Sep 15 12:52:45 2008
@@ -47,6 +47,8 @@
int add_header_count;
char add_header[MAX_ADD_HEADERS][MAX_STRING];
+
+ char user_agent[MAX_STRING];
} conf_t;
int conf_loadfile( conf_t *conf, char *file );
Modified: trunk/conn.c
URL: http://svn.debian.org/wsvn/axel/trunk/conn.c?rev=47&op=diff
==============================================================================
--- trunk/conn.c (original)
+++ trunk/conn.c Mon Sep 15 12:52:45 2008
@@ -257,6 +257,7 @@
conn->http->firstbyte = conn->currentbyte;
conn->http->lastbyte = conn->lastbyte;
http_get( conn->http, s );
+ http_addheader( conn->http, "User-Agent: %s", conn->conf->user_agent );
for( i = 0; i < conn->conf->add_header_count; i++)
http_addheader( conn->http, "%s", conn->conf->add_header[i] );
}
Modified: trunk/http.c
URL: http://svn.debian.org/wsvn/axel/trunk/http.c?rev=47&op=diff
==============================================================================
--- trunk/http.c (original)
+++ trunk/http.c Mon Sep 15 12:52:45 2008
@@ -103,7 +103,6 @@
http_addheader( conn, "GET %s HTTP/1.0", lurl );
http_addheader( conn, "Host: %s", conn->host );
}
- http_addheader( conn, "User-Agent: %s", USER_AGENT );
if( *conn->auth )
http_addheader( conn, "Authorization: Basic %s", conn->auth );
if( conn->firstbyte )
Modified: trunk/text.c
URL: http://svn.debian.org/wsvn/axel/trunk/text.c?rev=47&op=diff
==============================================================================
--- trunk/text.c (original)
+++ trunk/text.c Mon Sep 15 12:52:45 2008
@@ -53,6 +53,7 @@
{ "version", 0, NULL, 'V' },
{ "alternate", 0, NULL, 'a' },
{ "header", 1, NULL, 'H' },
+ { "user-agent", 1, NULL, 'U' },
{ NULL, 0, NULL, 0 }
};
#endif
@@ -89,12 +90,15 @@
{
int option;
- option = getopt_long( argc, argv, "s:n:o:S::NqvhVaH:", axel_options, NULL );
+ option = getopt_long( argc, argv, "s:n:o:S::NqvhVaH:U:", axel_options, NULL );
if( option == -1 )
break;
switch( option )
{
+ case 'U':
+ strncpy( conf->user_agent, optarg, MAX_STRING);
+ break;
case 'H':
strncpy( conf->add_header[cur_head++], optarg, MAX_STRING );
break;
@@ -528,6 +532,7 @@
"-o f\tSpecify local output file\n"
"-S [x]\tSearch for mirrors and download from x servers\n"
"-H x\tAdd header string\n"
+ "-U x\tSet user agent\n"
"-N\tJust don't use any proxy server\n"
"-q\tLeave stdout alone\n"
"-v\tMore status information\n"
@@ -544,6 +549,7 @@
"--output=f\t\t-o f\tSpecify local output file\n"
"--search[=x]\t\t-S [x]\tSearch for mirrors and download from x servers\n"
"--header=x\t\t-H x\tAdd header string\n"
+ "--user-agent=x\t\t-U x\tSet user agent\n"
"--no-proxy\t\t-N\tJust don't use any proxy server\n"
"--quiet\t\t\t-q\tLeave stdout alone\n"
"--verbose\t\t-v\tMore status information\n"
More information about the axel-commits
mailing list