taskrambler  v0.1.8
Web server and task management solution.
application/adapter/http/update.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include "application/application.h"
#include "application/adapter/http.h"
#include "hash.h"
#include "http/worker.h"
#include "http/header.h"
#include "http/message.h"
#include "router.h"
+ Include dependency graph for application/adapter/http/update.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define NO_SESSION_SID   NULL
 

Functions

static char * getSessionId (Hash cookies)
 
void applicationAdapterHttpUpdate (void *_this, void *subject)
 

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/update.c.

Macro Definition Documentation

#define _GNU_SOURCE

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

#define NO_SESSION_SID   NULL

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

Referenced by getSessionId().

Function Documentation

void applicationAdapterHttpUpdate ( void *  _this,
void *  subject 
)

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:

static char* getSessionId ( Hash  cookies)
inlinestatic

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

References CSTRA, hashGet(), and NO_SESSION_SID.

Referenced by applicationAdapterHttpUpdate().

42 {
43  HashValue sidstr = hashGet(cookies, CSTRA("sid"));
44 
45  if (NULL != sidstr) {
46  return (char*)sidstr->value;
47  }
48 
49  return NO_SESSION_SID;
50 }
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void * hashGet(Hash, const char *, size_t)
Definition: hash/get.c:51
#define NO_SESSION_SID

+ Here is the call graph for this function:

+ Here is the caller graph for this function: