|
|
|
@ -24,6 +24,7 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <time.h> |
|
|
|
#include <string.h> |
|
|
|
#include <sys/time.h> |
|
|
|
|
|
|
|
#include "class.h" |
|
|
|
@ -116,7 +117,7 @@ httpWorkerProcess(HttpWorker this, Stream st) |
|
|
|
* an empty 200 OK |
|
|
|
*/ |
|
|
|
if (NULL == password || NULL == username) { |
|
|
|
response = new(HttpResponse, "HTTP/1.1", 200, "OK"); |
|
|
|
response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); |
|
|
|
} |
|
|
|
|
|
|
|
if (NULL == response) { |
|
|
|
@ -126,11 +127,22 @@ httpWorkerProcess(HttpWorker this, Stream st) |
|
|
|
(char*)(password->value), password->nvalue); |
|
|
|
|
|
|
|
if (!authenticate(this->auth, cred)) { |
|
|
|
response = new(HttpResponse, "HTTP/1.1", 200, "OK"); |
|
|
|
response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); |
|
|
|
} else { |
|
|
|
if (NULL == this->session) { |
|
|
|
this->session = sessionAdd( |
|
|
|
this->sroot, |
|
|
|
new(Session, username->value, username->nvalue)); |
|
|
|
new(Session, |
|
|
|
username->value, |
|
|
|
username->nvalue)); |
|
|
|
} else { |
|
|
|
this->session->username = malloc(username->nvalue + 1); |
|
|
|
this->session->username[username->nvalue] = 0; |
|
|
|
memcpy(this->session->username, |
|
|
|
username->value, |
|
|
|
username->nvalue); |
|
|
|
} |
|
|
|
|
|
|
|
nbuf = sprintf(buffer, |
|
|
|
"sid=%lu;Path=/", |
|
|
|
this->session->id); |
|
|
|
@ -161,6 +173,15 @@ httpWorkerProcess(HttpWorker this, Stream st) |
|
|
|
response = (HttpMessage)httpResponseSession(this->session); |
|
|
|
} |
|
|
|
|
|
|
|
if (0 == strcmp("/sess/", request->path)) { |
|
|
|
if (NULL == this->session) { |
|
|
|
this->session = sessionAdd( |
|
|
|
this->sroot, |
|
|
|
new(Session, NULL, 0)); |
|
|
|
} |
|
|
|
response = (HttpMessage)httpResponseSession(this->session); |
|
|
|
} |
|
|
|
|
|
|
|
if (0 == strcmp("/randval/", request->path)) { |
|
|
|
if (NULL != this->session) { |
|
|
|
response = (HttpMessage)httpResponseRandval( |
|
|
|
|