}
else {
if (conn->priv->flags & RSPAMD_HTTP_CONN_FLAG_PROXY) {
- rspamd_printf_fstring (buf,
- "%s %s://%s:%d/%V HTTP/1.1\r\n"
- "Connection: %s\r\n"
- "Host: %s\r\n"
- "Content-Length: %z\r\n",
- http_method_str (msg->method),
- (msg->flags & RSPAMD_HTTP_FLAG_SSL) ? "https" : "http",
- host,
- msg->port,
- msg->url,
- conn_type,
- host,
- bodylen);
+ if ((msg->flags & RSPAMD_HTTP_FLAG_HAS_HOST_HEADER)) {
+ rspamd_printf_fstring(buf,
+ "%s %s://%s:%d/%V HTTP/1.1\r\n"
+ "Connection: %s\r\n"
+ "Content-Length: %z\r\n",
+ http_method_str(msg->method),
+ (msg->flags & RSPAMD_HTTP_FLAG_SSL) ? "https" : "http",
+ msg->port,
+ msg->url,
+ conn_type,
+ host,
+ bodylen);
+ }
+ else {
+ rspamd_printf_fstring(buf,
+ "%s %s://%s:%d/%V HTTP/1.1\r\n"
+ "Connection: %s\r\n"
+ "Host: %s\r\n"
+ "Content-Length: %z\r\n",
+ http_method_str(msg->method),
+ (msg->flags & RSPAMD_HTTP_FLAG_SSL) ? "https" : "http",
+ host,
+ msg->port,
+ msg->url,
+ conn_type,
+ host,
+ bodylen);
+ }
}
else {
- rspamd_printf_fstring (buf,
- "%s %V HTTP/1.1\r\n"
- "Connection: %s\r\n"
- "Host: %s\r\n"
- "Content-Length: %z\r\n",
- http_method_str (msg->method),
- msg->url,
- conn_type,
- host,
- bodylen);
+ if ((msg->flags & RSPAMD_HTTP_FLAG_HAS_HOST_HEADER)) {
+ rspamd_printf_fstring(buf,
+ "%s %V HTTP/1.1\r\n"
+ "Connection: %s\r\n"
+ "Content-Length: %z\r\n",
+ http_method_str(msg->method),
+ msg->url,
+ conn_type,
+ bodylen);
+ }
+ else {
+ rspamd_printf_fstring(buf,
+ "%s %V HTTP/1.1\r\n"
+ "Connection: %s\r\n"
+ "Host: %s\r\n"
+ "Content-Length: %z\r\n",
+ http_method_str(msg->method),
+ msg->url,
+ conn_type,
+ host,
+ bodylen);
+ }
}
if (bodylen > 0) {
hdr = g_malloc0 (sizeof (struct rspamd_http_header));
nlen = strlen (name);
vlen = len;
+
+ if (g_ascii_strcasecmp (name, "host") == 0) {
+ msg->flags |= RSPAMD_HTTP_FLAG_HAS_HOST_HEADER;
+ }
+
hdr->combined = rspamd_fstring_sized_new (nlen + vlen + 4);
rspamd_printf_fstring (&hdr->combined, "%s: %*s\r\n", name, (gint)vlen,
value);
cbd->item = rspamd_symcache_get_cur_item (task);
}
- if (msg->host) {
+
+ const rspamd_ftok_t *host_header_tok = rspamd_http_message_find_header (msg, "Host");
+ if (host_header_tok != NULL) {
+ if (msg->host) {
+ g_string_free (msg->host, true);
+ }
+ msg->host = g_string_new_len (host_header_tok->begin, host_header_tok->len);
cbd->host = msg->host->str;
}
+ else {
+ if (msg->host) {
+ cbd->host = msg->host->str;
+ }
+ }
if (body) {
if (gzip) {