.begin = "Date",
.len = 4
};
-
+static const rspamd_ftok_t last_modified_header = {
+ .begin = "Last-Modified",
+ .len = 13
+};
#define HTTP_ERROR http_error_quark ()
GQuark
else if (rspamd_ftok_casecmp (priv->header->name, &key_header) == 0) {
rspamd_http_parse_key (priv->header->value, conn, priv);
}
+ else if (rspamd_ftok_casecmp (priv->header->name, &last_modified_header) == 0) {
+ priv->msg->last_modified = rspamd_http_parse_date (
+ priv->header->value->begin,
+ priv->header->value->len);
+ }
}
static gint
return res;
}
+
+
+glong
+rspamd_http_date_format (gchar *buf, gsize len, time_t time)
+{
+ struct tm tms;
+
+ tms = *gmtime (&time);
+
+ return rspamd_snprintf (buf, len, "%s, %02d %s %4d %02d:%02d:%02d GMT",
+ http_week[tms.tm_wday], tms.tm_mday,
+ http_month[tms.tm_mon], tms.tm_year + 1900,
+ tms.tm_hour, tms.tm_min, tms.tm_sec);
+}
struct rspamd_http_message {
rspamd_fstring_t *url;
rspamd_fstring_t *host;
- unsigned port;
rspamd_fstring_t *status;
struct rspamd_http_header *headers;
rspamd_fstring_t *body;
rspamd_ftok_t body_buf;
struct rspamd_cryptobox_pubkey *peer_key;
- enum http_parser_type type;
time_t date;
+ time_t last_modified;
+ unsigned port;
+ enum http_parser_type type;
gint code;
enum http_method method;
gint flags;
*/
GHashTable* rspamd_http_message_parse_query (struct rspamd_http_message *msg);
+/**
+ * Prints HTTP date from `time` to `buf` using standard HTTP date format
+ * @param buf date buffer
+ * @param len length of buffer
+ * @param time time in unix seconds
+ * @return number of bytes written
+ */
+glong rspamd_http_date_format (gchar *buf, gsize len, time_t time);
+
#endif /* HTTP_H_ */