Explorar el Código

Fix lua_http.

tags/1.0.5
Vsevolod Stakhov hace 8 años
padre
commit
ee9def66ca
Se han modificado 2 ficheros con 10 adiciones y 10 borrados
  1. 1
    1
      src/libutil/map.c
  2. 9
    9
      src/lua/lua_http.c

+ 1
- 1
src/libutil/map.c Ver fichero

@@ -111,7 +111,7 @@ write_http_request (struct http_callback_data *cbd)

msg = rspamd_http_new_message (HTTP_REQUEST);

msg->url = g_string_new (cbd->data->path);
msg->url = rspamd_fstring_new_init (cbd->data->path, strlen (cbd->data->path));
if (cbd->data->last_checked != 0) {
tm = gmtime (&cbd->data->last_checked);
strftime (datebuf, sizeof (datebuf), "%a, %d %b %Y %H:%M:%S %Z", tm);

+ 9
- 9
src/lua/lua_http.c Ver fichero

@@ -168,7 +168,9 @@ lua_http_finish_handler (struct rspamd_http_connection *conn,
/* Headers */
lua_newtable (cbd->L);
LL_FOREACH (msg->headers, h) {
rspamd_lua_table_set (cbd->L, h->name->str, h->value->str);
lua_pushlstring (cbd->L, h->name->begin, h->name->len);
lua_pushlstring (cbd->L, h->value->begin, h->value->len);
lua_settable (cbd->L, -3);
}
if (lua_pcall (cbd->L, 4, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
@@ -269,8 +271,9 @@ lua_http_push_headers (lua_State *L, struct rspamd_http_message *msg)
static gint
lua_http_request (lua_State *L)
{
const gchar *url;
const gchar *url, *lua_body;
gint cbref;
gsize bodylen;
struct event_base *ev_base;
struct rspamd_http_message *msg;
struct lua_http_cbdata *cbd;
@@ -403,17 +406,14 @@ lua_http_request (lua_State *L)
lua_pushstring (L, "body");
lua_gettable (L, -2);
if (lua_type (L, -1) == LUA_TSTRING) {
msg->body = g_string_new (lua_tostring (L, -1));
lua_body = lua_tolstring (L, -1, &bodylen);
msg->body = rspamd_fstring_new_init (lua_body, bodylen);
}
else if (lua_type (L, -1) == LUA_TUSERDATA) {
t = lua_check_text (L, -1);
/* TODO: think about zero-copy possibilities */
if (t) {
/* XXX: is it safe ? */
msg->body = g_string_new (NULL);
msg->body->str = (gchar *)t->start;
msg->body->len = t->len;
/* It is not safe unless we set len to avoid body_buf to be freed */
msg->body_buf.len = t->len;
msg->body = rspamd_fstring_new_init (t->start, t->len);
}
}


Cargando…
Cancelar
Guardar