Browse Source

most stuff works...the session timeout will not be reset correctly within some answers, anyway it mostly works. refs #24

release0.1.5
Georg Hopp 12 years ago
parent
commit
e69a4962bb
  1. 6
      src/application/adapter/http/update.c
  2. 10
      src/application/session_update.c
  3. 68
      src/http/worker/process.c

6
src/application/adapter/http/update.c

@ -85,7 +85,8 @@ loginAdapter(Application application, HttpWorker worker, unsigned long sid)
char buffer[200];
size_t nbuf;
if (NO_SESSION_SID == sid) {
if (NO_SESSION_SID == sid
|| NULL == applicationSessionGet(application, sid)) {
sid = applicationSessionStart(
application,
(char *)(username->value),
@ -139,7 +140,8 @@ applicationAdapterHttpUpdate(void * _this, void * subject)
}
if (0 == strcmp("/sess/", worker->current_request->path)) {
if (NO_SESSION_SID == sid) {
if (NO_SESSION_SID == sid
|| NULL == applicationSessionGet(this->application, sid)) {
sid = applicationSessionStart(this->application, NULL, 0);
}

10
src/application/session_update.c

@ -42,11 +42,13 @@ applicationSessionUpdate(
{
Session session = hashGetByVal(this->active_sessions, sid);
MEM_FREE(session->username);
if (NULL != session) {
MEM_FREE(session->username);
session->username = memMalloc(nname + 1);
session->username[nname] = 0;
memcpy(session->username, name, nname);
session->username = memMalloc(nname + 1);
session->username[nname] = 0;
memcpy(session->username, name, nname);
}
}
// vim: set ts=4 sw=4:

68
src/http/worker/process.c

@ -72,42 +72,44 @@ httpWorkerProcess(HttpWorker this, Stream st)
*/
subjectNotify(this);
if (0 == strcmp("POST", this->current_request->method)) {
/*
* we can't do post requests on our own...
*/
this->current_response = (HttpMessage)httpResponse500();
}
if (0 == strcmp("GET", this->current_request->method)) {
char html_asset[2048] = "./assets/html";
char base_asset[2048] = "./assets";
char main_asset[] = "/main.html";
char * asset_path = base_asset;
char * asset;
char * mime_type;
if (0 == strcmp("/", this->current_request->path)) {
asset = main_asset;
} else {
asset = this->current_request->path;
}
mime_type = strrchr(asset, '.');
if (NULL != mime_type) {
mime_type++;
mime_type = getMimeType(mime_type, strlen(mime_type));
if (NULL == this->current_response) {
if (0 == strcmp("POST", this->current_request->method)) {
/*
* we can't do post requests on our own...
*/
this->current_response = (HttpMessage)httpResponse500();
}
if (NULL != mime_type &&
0 == memcmp(mime_type, CSTRA("text/html"))) {
asset_path = html_asset;
if (0 == strcmp("GET", this->current_request->method)) {
char html_asset[2048] = "./assets/html";
char base_asset[2048] = "./assets";
char main_asset[] = "/main.html";
char * asset_path = base_asset;
char * asset;
char * mime_type;
if (0 == strcmp("/", this->current_request->path)) {
asset = main_asset;
} else {
asset = this->current_request->path;
}
mime_type = strrchr(asset, '.');
if (NULL != mime_type) {
mime_type++;
mime_type = getMimeType(mime_type, strlen(mime_type));
}
if (NULL != mime_type &&
0 == memcmp(mime_type, CSTRA("text/html"))) {
asset_path = html_asset;
}
strcat(asset_path, asset);
this->current_response =
httpWorkerGetAsset(this, asset_path);
}
strcat(asset_path, asset);
this->current_response =
httpWorkerGetAsset(this, asset_path);
}
if (NULL == this->current_response) {

Loading…
Cancel
Save