int verbose; /* must be int (used by getopt32) */
smallint flg_deny_all;
- unsigned rmt_ip;
-// TODO: get rid of rmt_port
- unsigned rmt_port; /* for set env REMOTE_PORT */
- char *rmt_ip_str; /* for set env REMOTE_ADDR */
+ unsigned rmt_ip; /* used for IP-based allow/deny rules */
+ time_t last_mod;
+ off_t ContentLength; /* -1 - unknown */
+ char *rmt_ip_str; /* for $REMOTE_ADDR and $REMOTE_PORT */
const char *bind_addr_or_port;
const char *g_query;
const char *found_mime_type;
const char *found_moved_temporarily;
- time_t last_mod;
- off_t ContentLength; /* -1 - unknown */
Htaccess_IP *ip_a_d; /* config allow/deny lines */
USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
#define verbose (G.verbose )
#define flg_deny_all (G.flg_deny_all )
#define rmt_ip (G.rmt_ip )
-#define rmt_port (G.rmt_port )
#define bind_addr_or_port (G.bind_addr_or_port)
#define g_query (G.g_query )
#define configFile (G.configFile )
value = "";
setenv(name, value, 1);
}
-static void setenv_long(const char *name, long value)
-{
- char buf[sizeof(value)*3 + 2];
- sprintf(buf, "%ld", value);
- setenv(name, buf, 1);
-}
#endif
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
static void decodeBase64(char *Data)
{
const unsigned char *in = (const unsigned char *)Data;
- // The decoded size will be at most 3/4 the size of the encoded
+ /* The decoded size will be at most 3/4 the size of the encoded */
unsigned ch = 0;
int i = 0;
cp = NULL;
if (cp) *cp = '\0'; /* delete :PORT */
setenv1("REMOTE_ADDR", p);
- if (cp) *cp = ':';
- }
- setenv1("HTTP_USER_AGENT", user_agent);
+ if (cp) {
+ *cp = ':';
#if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
- setenv_long("REMOTE_PORT", rmt_port);
+ setenv1("REMOTE_PORT", cp + 1);
#endif
+ }
+ }
+ setenv1("HTTP_USER_AGENT", user_agent);
if (bodyLen)
- setenv_long("CONTENT_LENGTH", bodyLen);
+ putenv(xasprintf("CONTENT_LENGTH=%d", bodyLen));
if (cookie)
setenv1("HTTP_COOKIE", cookie);
if (content_type)
* (IOW, server process doesn't need to waste 8k) */
iobuf = xmalloc(MAX_MEMORY_BUF);
- rmt_port = get_nport(&fromAddr->sa);
- rmt_port = ntohs(rmt_port);
rmt_ip = 0;
if (fromAddr->sa.sa_family == AF_INET) {
rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr);