struct rspamd_http_connection_private *priv;
gpointer ssl;
gint request_method;
- rspamd_fstring_t *prev_host;
+ GString *prev_host = NULL;
priv = conn->priv;
ssl = priv->ssl;
}
else {
if (prev_host) {
- rspamd_fstring_free (prev_host);
+ g_string_free (prev_host, TRUE);
}
}
}
}
if (msg->host) {
- new_msg->host = rspamd_fstring_new_init (msg->host->str,
- msg->host->len);
+ new_msg->host = g_string_new_len (msg->host->str, msg->host->len);
}
new_msg->method = msg->method;
}
}
else {
+
+ /* Client request */
if (conn->opts & RSPAMD_HTTP_CLIENT_KEEP_ALIVE) {
conn_type = "keep-alive";
}
/* Format request */
- enclen += msg->url->len + strlen (http_method_str (msg->method)) + 1;
+ enclen += RSPAMD_FSTRING_LEN (msg->url) +
+ strlen (http_method_str (msg->method)) + 1;
if (host == NULL && msg->host == NULL) {
/* Fallback to HTTP/1.0 */
}
else {
/* Normal HTTP/1.1 with Host */
+ if (host == NULL) {
+ host = msg->host->str;
+ }
+
if (encrypted) {
- if (host != NULL) {
- rspamd_printf_fstring (buf,
- "%s %s HTTP/1.1\r\n"
- "Connection: %s\r\n"
- "Host: %s\r\n"
- "Content-Length: %z\r\n"
- "Content-Type: application/octet-stream\r\n",
- "POST",
- "/post",
- conn_type,
- host,
- enclen);
- }
- else {
- rspamd_printf_fstring (buf,
- "%s %s HTTP/1.1\r\n"
- "Connection: %s\r\n"
- "Host: %V\r\n"
- "Content-Length: %z\r\n"
- "Content-Type: application/octet-stream\r\n",
- "POST",
- "/post",
- conn_type,
- msg->host,
- enclen);
- }
+ rspamd_printf_fstring (buf,
+ "%s %s HTTP/1.1\r\n"
+ "Connection: %s\r\n"
+ "Host: %s\r\n"
+ "Content-Length: %z\r\n"
+ "Content-Type: application/octet-stream\r\n",
+ "POST",
+ "/post",
+ conn_type,
+ host,
+ enclen);
}
else {
- if (host != NULL) {
- 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);
- }
- else {
- rspamd_printf_fstring (buf,
- "%s %V HTTP/1.1\r\n"
- "Connection: %s\r\n"
- "Host: %V\r\n"
- "Content-Length: %z\r\n",
- http_method_str (msg->method),
- msg->url,
- conn_type,
- msg->host,
- bodylen);
- }
+ 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) {
if (mime_type != NULL) {
}
}
- msg->host = rspamd_fstring_new_init (host, pu.field_data[UF_HOST].len);
+ msg->host = g_string_new_len (host, pu.field_data[UF_HOST].len);
msg->url = rspamd_fstring_append (msg->url, path, pathlen);
REF_INIT_RETAIN (msg, rspamd_http_message_free);
rspamd_fstring_free (msg->status);
}
if (msg->host != NULL) {
- rspamd_fstring_free (msg->host);
+ g_string_free (msg->host, TRUE);
}
if (msg->peer_key != NULL) {
rspamd_pubkey_unref (msg->peer_key);