summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HttpServer.cc19
-rw-r--r--src/Socket.cc10
2 files changed, 24 insertions, 5 deletions
diff --git a/src/HttpServer.cc b/src/HttpServer.cc
index 43594e9..917fc8b 100644
--- a/src/HttpServer.cc
+++ b/src/HttpServer.cc
@@ -184,9 +184,8 @@ void Balau::HttpWorker::readVariables(Http::StringMap & variables, char * str) {
char * val = strchr(str, '=');
- if (val) {
+ if (val)
*val++ = 0;
- }
String keyStr = httpUnescape(str);
String valStr = val ? httpUnescape(val) : String("");
variables[keyStr] = valStr;
@@ -260,6 +259,7 @@ bool Balau::HttpWorker::handleClient() {
String httpVersion;
Http::StringMap httpHeaders;
Http::StringMap variables;
+ Http::StringMap cookies;
Http::FileList files;
bool persistent = false;
bool upgrade = false;
@@ -402,7 +402,16 @@ bool Balau::HttpWorker::handleClient() {
String key = line.extract(0, colon);
String value = line.extract(colon + 1);
- httpHeaders[key] = value.trim();
+ if (key == "Cookie") {
+ int equal = value.strchr('=');
+ if (equal > 0) {
+ key = value.extract(0, equal).trim();
+ value = value.extract(equal + 1).trim();
+ cookies[key] = value;
+ }
+ } else {
+ httpHeaders[key] = value.trim();
+ }
}
} while(true);
@@ -499,7 +508,8 @@ bool Balau::HttpWorker::handleClient() {
// will handle this horror later...
Failure("multipart/form-data not supported for now");
} else {
- uint8_t * postData = (uint8_t *) malloc(length);
+ uint8_t * postData = (uint8_t *) malloc(length + 1);
+ postData[length] = 0;
while (true) {
try {
@@ -567,6 +577,7 @@ bool Balau::HttpWorker::handleClient() {
req.host = host;
req.uri = uri;
req.variables = variables;
+ req.cookies = cookies;
req.headers = httpHeaders;
req.files = files;
req.persistent = persistent;
diff --git a/src/Socket.cc b/src/Socket.cc
index e1778be..7f91e7b 100644
--- a/src/Socket.cc
+++ b/src/Socket.cc
@@ -548,7 +548,15 @@ ssize_t Balau::Socket::write(const void * buf, size_t count) throw (GeneralExcep
}
ssize_t Balau::Socket::recv(int sockfd, void *buf, size_t len, int flags) {
- return ::recv(sockfd, (char *) buf, len, flags);
+ ssize_t r = ::recv(sockfd, (char *) buf, len, flags);
+ if (r < 0) {
+#ifdef _WIN32
+ int err = WSAGetLastError();
+ if (err == WSAECONNABORTED)
+ return 0;
+#endif
+ }
+ return r;
}
ssize_t Balau::Socket::send(int sockfd, const void *buf, size_t len, int flags) {