taskrambler  0.1.9
Web server and task management solution.
application/adapter/http/http.c File Reference
#include <stdarg.h>
#include "class.h"
#include "router.h"
#include "application/application.h"
#include "application/adapter/http.h"
#include "utils/memory.h"
#include "interface/observer.h"
+ Include dependency graph for application/adapter/http/http.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

static int applicationAdapterHttpCtor (void *_this, va_list *params)
 
static void applicationAdapterHttpDtor (void *_this)
 
void applicationAdapterHttpUpdate (void *, void *)
 
 INIT_IFACE (Class, applicationAdapterHttpCtor, applicationAdapterHttpDtor, NULL)
 
 INIT_IFACE (Observer, applicationAdapterHttpUpdate)
 
 CREATE_CLASS (ApplicationAdapterHttp, NULL, IFACE(Class), IFACE(Observer))
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file application/adapter/http/http.c.

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file application/adapter/http/http.c.

Function Documentation

static int applicationAdapterHttpCtor ( void *  _this,
va_list *  params 
)
static

Definition at line 37 of file application/adapter/http/http.c.

38 {
39  ApplicationAdapterHttp this = _this;
40 
41  this->application = va_arg(*params, Application);
42  this->router = va_arg(*params, Router);
43 
44  return 0;
45 }
static void applicationAdapterHttpDtor ( void *  _this)
static

Definition at line 49 of file application/adapter/http/http.c.

50 {
51 }
void applicationAdapterHttpUpdate ( void *  ,
void *   
)

Definition at line 53 of file application/adapter/http/update.c.

References applicationSessionCleanup(), applicationSessionGet(), applicationSessionStart(), CSTRA, getSessionId(), queuePut(), and routerRoute().

54 {
55  ApplicationAdapterHttp this = _this;
56  HttpWorker worker = (HttpWorker)subject;
57  Session session = NULL;
58  time_t now = time(NULL);
59 
60  char * sid;
61  char buf[1000];
62  size_t nbuf;
63 
64  applicationSessionCleanup(this->application, now);
65 
66  sid = getSessionId(worker->current_request->cookies);
67  session = applicationSessionGet(this->application, sid);
68 
69  if (NULL == session) {
70  session = applicationSessionStart(this->application);
71  }
72 
73  // send session cookie
74  nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
75  queuePut(
76  worker->additional_headers,
77  new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
78 
79  worker->current_response = (HttpMessage)routerRoute(
80  this->router,
81  worker->current_request,
82  session);
83 }
Session applicationSessionGet(Application, const char *)
Definition: session_get.c:36
static char * getSessionId(Hash cookies)
void applicationSessionCleanup(Application, time_t)
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void queuePut(Queue, void *)
Definition: queue/put.c:27
Session applicationSessionStart(Application)
Definition: session_start.c:36
HttpResponse routerRoute(Router, HttpRequest, Session)
Definition: route.c:53

+ Here is the call graph for this function:

CREATE_CLASS ( ApplicationAdapterHttp  ,
NULL  ,
IFACE(Class)  ,
IFACE(Observer)   
)
INIT_IFACE ( Class  ,
applicationAdapterHttpCtor  ,
applicationAdapterHttpDtor  ,
NULL   
)
INIT_IFACE ( Observer  ,
applicationAdapterHttpUpdate   
)