Browse Source
closes #10: values for header ids are now stored in a char ** making multiple values for one id possible. Additionally added a jquery action that delivers the jquery java script and use it on the me action
master
closes #10: values for header ids are now stored in a char ** making multiple values for one id possible. Additionally added a jquery action that delivers the jquery java script and use it on the me action
master
17 changed files with 179 additions and 44 deletions
-
8ChangeLog
-
11include/http/header.h
-
1include/http/response.h
-
1src/Makefile.am
-
15src/http/header.c
-
8src/http/header/add.c
-
4src/http/header/get.c
-
7src/http/header/size_get.c
-
17src/http/header/to_string.c
-
11src/http/message/has_keep_alive.c
-
2src/http/message/header_size_get.c
-
2src/http/message/header_to_string.c
-
6src/http/request/parser/get_body.c
-
78src/http/response/jquery.c
-
25src/http/response/me.c
-
13src/http/worker/process.c
-
14src/testserver.c
@ -0,0 +1,78 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright (C) 2012 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/>. |
|||
*/ |
|||
|
|||
#include <stdio.h> |
|||
#include <time.h> |
|||
#include <sys/stat.h> |
|||
#include <fcntl.h> |
|||
|
|||
#include "class.h" |
|||
#include "interface/class.h" |
|||
|
|||
#include "http/response.h" |
|||
#include "http/message.h" |
|||
#include "http/header.h" |
|||
|
|||
|
|||
HttpResponse |
|||
httpResponseJquery(int handle) |
|||
{ |
|||
time_t t; |
|||
struct tm * tmp; |
|||
char buffer[200]; |
|||
struct stat st; |
|||
HttpResponse response; |
|||
HttpMessage message; |
|||
|
|||
fstat(handle, &st); |
|||
|
|||
response = new(HttpResponse, "HTTP/1.1", 200, "OK"); |
|||
message = (HttpMessage)response; |
|||
|
|||
httpHeaderAdd(&(message->header), |
|||
new(HttpHeader, "Content-Type", "text/javascript")); |
|||
httpHeaderAdd(&(message->header), |
|||
new(HttpHeader, "Server", "testserver")); |
|||
|
|||
message->type = HTTP_MESSAGE_PIPED; |
|||
message->handle = handle; |
|||
message->nbody = st.st_size; |
|||
|
|||
sprintf(buffer, "%d", message->nbody); |
|||
httpHeaderAdd(&(message->header), |
|||
new(HttpHeader, "Content-Length", buffer)); |
|||
|
|||
tmp = localtime(&(st.st_mtime)); |
|||
strftime(buffer, sizeof(buffer), "%s", tmp); |
|||
httpHeaderAdd(&(message->header), |
|||
new(HttpHeader, "ETag", buffer)); |
|||
|
|||
t = time(NULL); |
|||
tmp = localtime(&t); |
|||
strftime(buffer, sizeof(buffer), "%a, %d %b %Y %T %Z", tmp); |
|||
httpHeaderAdd(&(message->header), |
|||
new(HttpHeader, "Date", buffer)); |
|||
|
|||
return response; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue