예제 #1
0
void guava_router_static_free(guava_router_static_t *router) {
  if (!router) {
    return;
  }

  if (router->route.mount_point) {
    guava_string_free(router->route.mount_point);
  }

  if (router->route.package) {
    guava_string_free(router->route.package);
  }

  if (router->route.session_store) {
    guava_session_store_free(router->route.session_store);
  }

  if (router->route.routes) {
    Py_DECREF(router->route.routes);
  }

  if (router->directory) {
    guava_string_free(router->directory);
  }

  guava_free(router);
}
예제 #2
0
guava_request_t *guava_request_new(void) {
  guava_request_t *req = (guava_request_t *)guava_calloc(1, sizeof(guava_request_t));
  if (!req) {
    return NULL;
  }

  req->url = NULL;
  req->path = NULL;
  req->host = NULL;
  req->body = NULL;

  req->headers = PyDict_New();
  if (!req->headers) {
    guava_free(req);
    return NULL;
  }

  req->major = 1;
  req->minor = 1;
  req->method = HTTP_GET;

  req->GET = PyDict_New();
  if (!req->GET) {
    Py_DECREF(req->headers);
    guava_free(req);
    return NULL;
  }

  req->POST = PyDict_New();
  if (!req->POST) {
    Py_DECREF(req->headers);
    Py_DECREF(req->GET);
    guava_free(req);
    return NULL;
  }

  req->COOKIES = PyDict_New();
  if (!req->COOKIES) {
    Py_DECREF(req->headers);
    Py_DECREF(req->GET);
    Py_DECREF(req->POST);
    guava_free(req);
    return NULL;
  }

  return req;
}
예제 #3
0
void guava_request_free(guava_request_t *req) {
  if (req->url) {
    guava_string_free(req->url);
    req->url = NULL;
  }

  if (req->path) {
    guava_string_free(req->path);
    req->path = NULL;
  }

  if (req->host) {
    guava_string_free(req->host);
    req->host = NULL;
  }

  if (req->body) {
    guava_string_free(req->body);
    req->body = NULL;
  }

  if (req->headers) {
    Py_DECREF(req->headers);
    req->headers = NULL;
  }

  if (req->GET) {
    Py_DECREF(req->GET);
    req->GET = NULL;
  }

  if (req->POST) {
    Py_DECREF(req->POST);
    req->POST = NULL;
  }

  if (req->COOKIES) {
    Py_DECREF(req->COOKIES);
    req->COOKIES = NULL;
  }

  guava_free(req);
}