-const char parsers_rcs[] = "$Id: parsers.c,v 1.22 2001/09/10 10:58:53 oes Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.23 2001/09/12 18:08:19 steudten Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.23 2001/09/12 18:08:19 steudten
+ *
+ * In parse_http_request() header rewriting miss the host value, so
+ * from http://www.mydomain.com the result was just " / " not
+ * http://www.mydomain.com/ in case we forward.
+ *
* Revision 1.22 2001/09/10 10:58:53 oes
* Silenced compiler warnings
*
* Returns : Always NULL.
*
*********************************************************************/
-char *crumble(const struct parsers *v, char *s, struct client_state *csp)
+char *crumble(const struct parsers *v, const char *s, struct client_state *csp)
{
log_error(LOG_LEVEL_HEADER, "crunch!");
return(NULL);
* Returns : A duplicate string pointer to this header (ie. pass thru)
*
*********************************************************************/
-char *content_type(const struct parsers *v, char *s, struct client_state *csp)
+char *content_type(const struct parsers *v, const char *s, struct client_state *csp)
{
if (strstr(s, " text/") || strstr(s, "application/x-javascript"))
csp->content_type = CT_TEXT;
* Returns : A duplicate string pointer to this header (ie. pass thru)
*
*********************************************************************/
-char *content_length(const struct parsers *v, char *s, struct client_state *csp)
+char *content_length(const struct parsers *v, const char *s, struct client_state *csp)
{
if (csp->content_length != 0) /* Content has been modified */
{
- s = (char *) zalloc(100);
- sprintf(s, "Content-Length: %d", csp->content_length);
+ char * s2 = (char *) zalloc(100);
+ sprintf(s2, "Content-Length: %d", csp->content_length);
- log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
- return(s);
+ log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
+ return(s2);
}
else
{
* or modified header
*
*********************************************************************/
-char *client_referrer(const struct parsers *v, char *s, struct client_state *csp)
+char *client_referrer(const struct parsers *v, const char *s, struct client_state *csp)
{
const char * newval;
+ char * s2;
#ifdef FEATURE_FORCE_LOAD
/* Since the referrer can include the prefix even
* even if the request itself is non-forced, we must
* to fool stupid checks for in-site links
*/
log_error(LOG_LEVEL_HEADER, "crunch+forge!");
- s = strsav(NULL, "Referer: ");
- s = strsav(s, "http://");
- s = strsav(s, csp->http->hostport);
- s = strsav(s, "/");
- return(s);
+ s2 = strsav(NULL, "Referer: ");
+ s2 = strsav(s2, "http://");
+ s2 = strsav(s2, csp->http->hostport);
+ s2 = strsav(s2, "/");
+ return(s2);
}
/*
/*
* We have a specific (fixed) referer we want to send.
*/
+ char * s2;
log_error(LOG_LEVEL_HEADER, "modified");
- s = strsav( NULL, "Referer: " );
- s = strsav( s, newval );
- return(s);
+ s2 = strsav( NULL, "Referer: " );
+ s2 = strsav( s2, newval );
+ return(s2);
}
/* Should never get here! */
* to fool stupid checks for in-site links
*/
log_error(LOG_LEVEL_HEADER, "crunch+forge!");
- s = strsav(NULL, "Referer: ");
- s = strsav(s, "http://");
- s = strsav(s, csp->http->hostport);
- s = strsav(s, "/");
- return(s);
+ s2 = strsav(NULL, "Referer: ");
+ s2 = strsav(s2, "http://");
+ s2 = strsav(s2, csp->http->hostport);
+ s2 = strsav(s2, "/");
+ return(s2);
}
* a malloc'ed string pointer to this header (ie. pass thru).
*
*********************************************************************/
-char *client_uagent(const struct parsers *v, char *s, struct client_state *csp)
+char *client_uagent(const struct parsers *v, const char *s, struct client_state *csp)
{
const char * newval;
+ char * s2;
/* Save the client's User-Agent: value */
if (strlen(s) >= 12)
log_error(LOG_LEVEL_HEADER, "modified");
- s = strsav( NULL, "User-Agent: " );
- s = strsav( s, newval );
- return(s);
+ s2 = strsav( NULL, "User-Agent: " );
+ s2 = strsav( s2, newval );
+ return(s2);
}
* Returns : NULL if crunched, or a malloc'ed string to original header
*
*********************************************************************/
-char *client_ua(const struct parsers *v, char *s, struct client_state *csp)
+char *client_ua(const struct parsers *v, const char *s, struct client_state *csp)
{
if ((csp->action->flags & ACTION_HIDE_USER_AGENT) == 0)
{
* modified/original header.
*
*********************************************************************/
-char *client_from(const struct parsers *v, char *s, struct client_state *csp)
+char *client_from(const struct parsers *v, const char *s, struct client_state *csp)
{
const char * newval;
+ char * s2;
if ((csp->action->flags & ACTION_HIDE_FROM) == 0)
{
log_error(LOG_LEVEL_HEADER, " modified");
- s = strsav( NULL, "From: " );
- s = strsav( s, newval );
- return(s);
+ s2 = strsav( NULL, "From: " );
+ s2 = strsav( s2, newval );
+ return(s2);
}
* Returns : Always NULL.
*
*********************************************************************/
-char *client_send_cookie(const struct parsers *v, char *s, struct client_state *csp)
+char *client_send_cookie(const struct parsers *v, const char *s, struct client_state *csp)
{
if ((csp->action->flags & ACTION_NO_COOKIE_READ) == 0)
{
* Returns : Always NULL.
*
*********************************************************************/
-char *client_x_forwarded(const struct parsers *v, char *s, struct client_state *csp)
+char *client_x_forwarded(const struct parsers *v, const char *s, struct client_state *csp)
{
if ((csp->action->flags & ACTION_HIDE_FORWARDED) == 0)
{
* Returns : Duplicate of argument s.
*
*********************************************************************/
-char *client_accept(const struct parsers *v, char *s, struct client_state *csp)
+char *client_accept(const struct parsers *v, const char *s, struct client_state *csp)
{
#ifdef FEATURE_IMAGE_DETECT_MSIE
if (strstr (s, "image/gif"))
*********************************************************************/
void client_xtra_adder(struct client_state *csp)
{
- struct list *lst = csp->action->multi[ACTION_MULTI_ADD_HEADER];
+ struct list *lst;
- for (lst = lst->next; lst ; lst = lst->next)
+ for (lst = csp->action->multi[ACTION_MULTI_ADD_HEADER]->next;
+ lst ; lst = lst->next)
{
log_error(LOG_LEVEL_HEADER, "addh: %s", lst->str);
enlist(csp->headers, lst->str);
* Returns : `crumble' or a newly malloc'ed string.
*
*********************************************************************/
-char *server_set_cookie(const struct parsers *v, char *s, struct client_state *csp)
+char *server_set_cookie(const struct parsers *v, const char *s, struct client_state *csp)
{
#ifdef FEATURE_COOKIE_JAR
if (csp->config->jar)
* Returns : A malloc'ed pointer to the cleaned host header
*
*********************************************************************/
-char *client_host(const struct parsers *v, char *s, struct client_state *csp)
+char *client_host(const struct parsers *v, const char *s, struct client_state *csp)
{
char *cleanhost = strdup(s);
#ifndef PARSERS_H_INCLUDED
#define PARSERS_H_INCLUDED
-#define PARSERS_H_VERSION "$Id: parsers.h,v 1.10 2001/07/30 22:08:36 jongfoster Exp $"
+#define PARSERS_H_VERSION "$Id: parsers.h,v 1.11 2001/07/31 14:46:53 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.h,v $
*
* Revisions :
* $Log: parsers.h,v $
+ * Revision 1.11 2001/07/31 14:46:53 oes
+ * Added prototype for connection_close_adder
+ *
* Revision 1.10 2001/07/30 22:08:36 jongfoster
* Tidying up #defines:
* - All feature #defines are now of the form FEATURE_xxx
extern void free_http_request(struct http_request *http);
extern void parse_http_request(char *req, struct http_request *http, struct client_state *csp);
-extern char *crumble(const struct parsers *v, char *s, struct client_state *csp);
+extern char *crumble(const struct parsers *v, const char *s, struct client_state *csp);
-extern char *client_referrer(const struct parsers *v, char *s, struct client_state *csp);
-extern char *client_uagent(const struct parsers *v, char *s, struct client_state *csp);
-extern char *client_ua(const struct parsers *v, char *s, struct client_state *csp);
-extern char *client_from(const struct parsers *v, char *s, struct client_state *csp);
-extern char *client_send_cookie(const struct parsers *v, char *s, struct client_state *csp);
-extern char *client_x_forwarded(const struct parsers *v, char *s, struct client_state *csp);
+extern char *client_referrer(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *client_uagent(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *client_ua(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *client_from(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *client_send_cookie(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *client_x_forwarded(const struct parsers *v, const char *s, struct client_state *csp);
extern void client_cookie_adder(struct client_state *csp);
extern void client_xtra_adder(struct client_state *csp);
extern void connection_close_adder(struct client_state *csp);
extern void client_x_forwarded_adder(struct client_state *csp);
-extern char *server_set_cookie(const struct parsers *v, char *s, struct client_state *csp);
+extern char *server_set_cookie(const struct parsers *v, const char *s, struct client_state *csp);
-extern char *content_type(const struct parsers *v, char *s, struct client_state *csp);
-extern char *content_length(const struct parsers *v, char *s, struct client_state *csp);
+extern char *content_type(const struct parsers *v, const char *s, struct client_state *csp);
+extern char *content_length(const struct parsers *v, const char *s, struct client_state *csp);
#ifdef FEATURE_FORCE_LOAD
-char *client_host(const struct parsers *v, char *s, struct client_state *csp);
+char *client_host(const struct parsers *v, const char *s, struct client_state *csp);
int strclean(const char *string, const char *substring);
#endif /* def FEATURE_FORCE_LOAD */
#if defined(FEATURE_IMAGE_DETECT_MSIE)
-extern char *client_accept(const struct parsers *v, char *s, struct client_state *csp);
+extern char *client_accept(const struct parsers *v, const char *s, struct client_state *csp);
#endif /* defined(FEATURE_IMAGE_DETECT_MSIE) */
/* Revision control strings from this header and associated .c file */