Changeset 642 for trollforge/lastmeasure
- Timestamp:
- 01/20/12 02:26:06 (16 months ago)
- Location:
- trollforge/lastmeasure/server
- Files:
-
- 2 edited
-
lmresource.h (modified) (2 diffs)
-
lmserver.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trollforge/lastmeasure/server/lmresource.h
r640 r642 97 97 98 98 static Response Get(char const *resource, char const *query, 99 char const *host, char const *agent )99 char const *host, char const *agent, int *flags) 100 100 { 101 101 /* Special case for server status (TODO) */ … … 113 113 return Response(m_statics[i], MimeType(resource)); 114 114 } 115 } 116 117 /* Special case for gzipped data -- just a test for now */ 118 if (!strcmp(resource, "/gnaa.txt")) 119 { 120 *flags |= 1; 121 return Response(std::string( 122 "\x1f\x8b\x08\x00\x7d\xb7\x18\x4f\x02\x03\xec\xd1" 123 "\x41\x0a\x80\x20\x10\x05\xd0\x7d\xe0\x1d\xbc\x8a" 124 "\xab\x56\xb5\xea\xfe\x67\x89\x10\x29\x4d\xc3\x4d" 125 "\xbb\x97\x04\x4e\xcc\x9f\xb2\x17\x96\x18\xd7\x3d" 126 "\xa5\xeb\x8e\xb1\xde\xe7\xab\x5f\x1d\x5b\x58\x4a" 127 "\x6f\x7e\x56\x57\xed\xa4\x52\xe5\x54\x3d\xaf\x9e" 128 "\x71\xbf\xe5\x59\xf5\x72\xfd\xce\x51\x6e\xd4\xd9" 129 "\x3f\xc1\x7f\xb9\xaf\xef\x9c\xf9\x13\x6d\xee\xed" 130 "\x37\x97\x2b\x8b" 131 "\x3f\x7f\xfe\xfc\xf9\xf3\xe7\xcf\x9f", 109), "text/plain"); 115 132 } 116 133 -
trollforge/lastmeasure/server/lmserver.cpp
r577 r642 249 249 /* Now build the response */ 250 250 std::stringstream response(""); 251 Response data = Resources::Get(resource, query, host, agent); 251 int flags = 0; 252 Response data = Resources::Get(resource, query, host, agent, &flags); 252 253 response << "HTTP/1.1 200 OK\r\n" 253 254 << "Date: " << Utils::Time() << "\r\n" 254 << "Server: " << Random::ServerName() << "\r\n" 255 << "Content-Length: " << data.first.length() << "\r\n" 256 //<< "Connection: Keep-Alive\r\n" 255 << "Server: " << Random::ServerName() << "\r\n"; 256 257 if (flags & 1) 258 response << "Content-Encoding: gzip\r\n"; 259 else 260 response << "Content-Length: " << data.first.length() << "\r\n"; 261 262 response //<< "Connection: Keep-Alive\r\n" 257 263 << "Connection: Close\r\n" 258 264 << "Content-Type: " << data.second << "\r\n" … … 262 268 send(client, response.str().c_str(), response.str().length(), 0); 263 269 270 /* Send gzipped data for fun. Not very useful yet */ 271 if (flags & 1) 272 { 273 char const *data = response.str().c_str() + response.str().length() - 9; 274 for (int i = 0; i < 800000; i++) 275 send(client, data, 9, 0); 276 } 277 264 278 /* FIXME: we could reuse the connection here */ 265 279 close(client);
Note: See TracChangeset
for help on using the changeset viewer.
