X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp.c;h=a327cf32558efba6e925482c119daf7ef99c9b94;hb=d716fe118643f845b127b5a12be8b6a08d735a82;hp=98b9489ac6be3a607301d70711d2e5e3ed8375ba;hpb=f90756452fe633919671e11dbc1b9e21eca0e1e7;p=pazpar2-moved-to-github.git diff --git a/src/http.c b/src/http.c index 98b9489..a327cf3 100644 --- a/src/http.c +++ b/src/http.c @@ -1,5 +1,5 @@ /* - * $Id: http.c,v 1.20 2007-03-31 20:27:15 marc Exp $ + * $Id: http.c,v 1.21 2007-04-02 09:43:08 marc Exp $ */ #include @@ -21,10 +21,11 @@ #endif #include +#include #include #include -#include +#include #include "cconfig.h" #include "util.h" @@ -39,6 +40,7 @@ static void http_destroy(IOCHAN i); extern IOCHAN channel_list; extern struct parameters global_parameters; +//extern NMEM nmem; // If this is set, we proxy normal HTTP requests static struct sockaddr_in *proxy_addr = 0; @@ -988,16 +990,37 @@ void http_init(const char *addr) yaz_log(YLOG_FATAL, "Unable to resolve '%s'", hostname); exit(1); } + memcpy(&myaddr.sin_addr.s_addr, he->h_addr_list[0], he->h_length); port = atoi(pp + 1); + + yaz_log(YLOG_LOG, "HTTP address %s:%d", + "" == he->h_addr_list[0] ? he->h_addr_list[0] : "127.0.0.1" , + port); + } else { + //size_t len = 128; + //char h[len]; port = atoi(addr); myaddr.sin_addr.s_addr = INADDR_ANY; + +#if 0 + // get hostname from system - after deciding to bind to any + // IP address this box might have. + if (0 == gethostname(h, len)){ + h[len - 1] = '\0'; + global_parameters.server->host = nmem_strdup(nmem, h); + } else + yaz_log(YLOG_WARN, "Could not get host name"); +#endif } + + myaddr.sin_port = htons(port); + if (!(p = getprotobyname("tcp"))) { abort(); }