blob: 09b1949c97ed2a268efc8c17f60d4d95f72120ca [file] [log] [blame]
diff --git a/htpdate.c b/htpdate.c
index aa66e9f..d0e7fbb 100644
--- a/htpdate.c
+++ b/htpdate.c
@@ -146,7 +146,7 @@ static void printlog( int is_error, char *format, ... ) {
}
-static long getHTTPdate( char *host, char *port, char *proxy, char *proxyport, char *httpversion, int ipversion, int when ) {
+static long getHTTPdate( char *host, char *port, char *proxy, char *proxyport, char *relpath, char *httpversion, int ipversion, int when ) {
int server_s;
int rc;
struct addrinfo hints, *res, *res0;
@@ -196,7 +196,7 @@ static long getHTTPdate( char *host, char *port, char *proxy, char *proxyport, c
Connection: close, allows the server the immediately close the
connection after sending the response.
*/
- snprintf(buffer, BUFFERSIZE, "HEAD %s/ HTTP/1.%s\r\nHost: %s\r\nUser-Agent: htpdate/"VERSION"\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nConnection: close\r\n\r\n", url, httpversion, host);
+ snprintf(buffer, BUFFERSIZE, "HEAD %s/%s HTTP/1.%s\r\nHost: %s\r\nUser-Agent: htpdate/"VERSION"\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nConnection: close\r\n\r\n", url, relpath, httpversion, host);
/* Loop through the available canonical names */
res = res0;
@@ -433,7 +433,7 @@ static void showhelp() {
puts("htpdate version "VERSION"\n\
Usage: htpdate [-046abdhlqstxD] [-i pid file] [-m minpoll] [-M maxpoll]\n\
[-p precision] [-P <proxyserver>[:port]] [-u user[:group]]\n\
- <host[:port]> ...\n\n\
+ [-r relative/path] <host[:port]> ...\n\n\
-0 HTTP/1.0 request\n\
-4 Force IPv4 name resolution only\n\
-6 Force IPv6 name resolution only\n\
@@ -449,6 +449,7 @@ Usage: htpdate [-046abdhlqstxD] [-i pid file] [-m minpoll] [-M maxpoll]\n\
-p precision (ms)\n\
-P proxy server\n\
-q query only, don't make time changes (default)\n\
+ -r relative path to add the URL for the HTTP request\n\
-s set time\n\
-t turn off sanity time check\n\
-u run daemon as user\n\
@@ -530,6 +531,7 @@ static void runasdaemon( char *pidfile ) {
int main( int argc, char *argv[] ) {
char *host = NULL, *proxy = NULL, *proxyport = NULL;
char *port;
+ char *relpath = "";
char *httpversion = DEFAULT_HTTP_VERSION;
char *pidfile = DEFAULT_PID_FILE;
char *user = NULL, *userstr = NULL, *group = NULL;
@@ -557,7 +559,7 @@ int main( int argc, char *argv[] ) {
/* Parse the command line switches and arguments */
- while ( (param = getopt(argc, argv, "046abdhi:lm:p:qstu:wxDM:P:") ) != -1)
+ while ( (param = getopt(argc, argv, "046abdhi:lm:p:qr:stu:wxDM:P:") ) != -1)
switch( param ) {
case '0': /* HTTP/1.0 */
@@ -604,6 +606,9 @@ int main( int argc, char *argv[] ) {
break;
case 'q': /* query only */
break;
+ case 'r': /* relative path for the URL */
+ relpath = (char *)optarg;
+ break;
case 's': /* set time */
setmode = 2;
break;
@@ -744,7 +749,7 @@ int main( int argc, char *argv[] ) {
if ( debug ) printlog( 0, "burst: %d try: %d when: %d", \
burst + 1, MAX_ATTEMPT - try + 1, when );
timestamp = getHTTPdate( host, port, proxy, proxyport,\
- httpversion, ipversion, when );
+ relpath, httpversion, ipversion, when );
try--;
} while ( timestamp && try );