Exemple #1
0
static int
mtev_lua_rest_acl_func(lua_State *L) {
  const char *acl_type;
  CCALL_DECL(L, mtev_http_rest_closure_t, restc, 1);
  lua_pushboolean(L, mtev_http_rest_client_cert_auth(restc, 0, NULL));
  return 1;
}
Exemple #2
0
static int
mtev_lua_http_option_set(lua_State *L) {
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 2);
  u_int32_t opt = lua_tointeger(L,2);
  lua_pushboolean(L, mtev_http_response_option_set(http_ctx, opt));
  return 1;
}
Exemple #3
0
static int
mtev_lua_http_status_set(lua_State *L) {
  const char *val;
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 3);
  val = lua_tostring(L,3);
  val = val ? val : "YeeHaw";
  mtev_http_response_status_set(http_ctx, lua_tointeger(L,2), val);
  return 0;
}
Exemple #4
0
static int
mtev_lua_http_request_opts(lua_State *L) {
  CCALL_DECL(L, mtev_http_request, req, 0);
  if(lua_gettop(L) == 1) {
    lua_pushinteger(L, mtev_http_request_opts(req));
    return 1;
  }
  mtev_http_request_set_opts(req, lua_tointeger(L,2));
  return 0;
}
Exemple #5
0
static int
mtev_lua_http_header_set(lua_State *L) {
  const char *hdr, *val;
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 3);
  hdr = lua_tostring(L,2);
  val = lua_tostring(L,3);
  if(!hdr || !val) luaL_error(L, "invalid header or headervalue");
  mtev_http_response_header_set(http_ctx, hdr, val);
  return 0;
}
Exemple #6
0
static int
mtev_lua_http_request_payload(lua_State *L) {
  const void *payload = NULL;
  int64_t size;
  CCALL_DECL(L, mtev_http_request, req, 1);
  payload = mtev_http_request_get_upload(req, &size);
  if(payload)
    lua_pushlstring(L, (char *)payload, size);
  else
    lua_pushnil(L);
  return 1;
}
Exemple #7
0
static int
mtev_lua_http_write(lua_State *L) {
  mtev_boolean status = mtev_false;
  size_t inlen;
  const char *message;
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 2);

  message = lua_tolstring(L, 2, &inlen);
  if(message)
    status = mtev_http_response_append(http_ctx, message, inlen);
  lua_pushboolean(L, status);
  return 1;
}
Exemple #8
0
static int
mtev_lua_http_request_querystring(lua_State *L) {
  mtev_hash_table *h;
  CCALL_DECL(L, mtev_http_request, req, 0);
  h = mtev_http_request_querystring_table(req);
  if(lua_gettop(L) == 1)
    mtev_lua_hash_to_table(L, h);
  else if(lua_gettop(L) == 2) {
    const char *key = lua_tostring(L,2), *value;
    if(key == NULL) lua_pushnil(L);
    else {
      if(mtev_hash_retr_str(h, key, strlen(key), &value))
        lua_pushstring(L, value);
      else
        lua_pushnil(L);
    }
  }
  else luaL_error(L, "invalid arguments to mtev_http_request:querystring()");
  return 1;
}
Exemple #9
0
static int
mtev_lua_http_request_headers(lua_State *L) {
  mtev_hash_table *h;
  CCALL_DECL(L, mtev_http_request, req, 0);
  h = mtev_http_request_headers_table(req);
  if(lua_gettop(L) == 1)
    mtev_lua_hash_to_table(L, h);
  else if(lua_gettop(L) == 2) {
    const char *hdr = lua_tostring(L,2);
    if(hdr == NULL) lua_pushnil(L);
    else {
      char *cp, *lower = alloca(strlen(hdr) + 1);
      memcpy(lower, hdr, strlen(hdr)+1);
      for(cp=lower; *cp; cp++) *cp = tolower(*cp);
      if(mtev_hash_retr_str(h, lower, strlen(lower), &hdr))
        lua_pushstring(L, hdr);
      else
        lua_pushnil(L);
    }
  }
  else luaL_error(L, "invalid arguments to mtev_http_request:headers()");
  return 1;
}
Exemple #10
0
static int
noit_lua_http_request_uri(lua_State *L) {
  CCALL_DECL(L, noit_http_request, req, 1);
  lua_pushstring(L, noit_http_request_uri_str(req));
  return 1;
}
Exemple #11
0
static int
mtev_lua_http_ctx_func(lua_State *L) {
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 1);
  mtev_lua_setup_http_ctx(L, http_ctx);
  return 1;
}
Exemple #12
0
static int
mtev_lua_http_request_func(lua_State *L) {
  CCALL_DECL(L, mtev_http_request, req, 1);
  mtev_lua_setup_http_request(L, req);
  return 1;
}
Exemple #13
0
static int
noit_lua_http_request_func(lua_State *L) {
  CCALL_DECL(L, noit_http_request, req, 1);
  noit_lua_setup_http_request(L, req);
  return 1;
}
Exemple #14
0
static int
noit_lua_http_ctx_func(lua_State *L) {
  CCALL_DECL(L, noit_http_session_ctx, http_ctx, 1);
  noit_lua_setup_http_ctx(L, http_ctx);
  return 1;
}
Exemple #15
0
static int
mtev_lua_http_flush(lua_State *L) {
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 1);
  mtev_http_response_flush(http_ctx, mtev_false);
  return 0;
}
Exemple #16
0
static int
mtev_lua_http_flush_and_end(lua_State *L) {
  CCALL_DECL(L, mtev_http_session_ctx, http_ctx, 1);
  mtev_http_response_end(http_ctx);
  return 0;
}
Exemple #17
0
static int
noit_lua_http_flush(lua_State *L) {
  CCALL_DECL(L, noit_http_session_ctx, http_ctx, 1);
  noit_http_response_flush(http_ctx, noit_false);
  return 0;
}
Exemple #18
0
static int
mtev_lua_http_request_method(lua_State *L) {
  CCALL_DECL(L, mtev_http_request, req, 1);
  lua_pushstring(L, mtev_http_request_method_str(req));
  return 1;
}