this will take a image from C328 serial camera and store those images in mbed flash as html and this html page is uploaded into the server at ip:192.168.1.2
lwip/HTTPServer/HTTPFields.h@0:e1a0471e5ffb, 2010-12-15 (annotated)
- Committer:
- mitesh2patel
- Date:
- Wed Dec 15 15:01:56 2010 +0000
- Revision:
- 0:e1a0471e5ffb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mitesh2patel | 0:e1a0471e5ffb | 1 | #ifndef HTTPATTRIBUTE_H |
mitesh2patel | 0:e1a0471e5ffb | 2 | #define HTTPATTRIBUTE_H |
mitesh2patel | 0:e1a0471e5ffb | 3 | |
mitesh2patel | 0:e1a0471e5ffb | 4 | #include "HTTPServer.h" |
mitesh2patel | 0:e1a0471e5ffb | 5 | |
mitesh2patel | 0:e1a0471e5ffb | 6 | /** |
mitesh2patel | 0:e1a0471e5ffb | 7 | * A simple HTTPHandler which will add new fields to the httpresult header. |
mitesh2patel | 0:e1a0471e5ffb | 8 | * It can be used for adding caching strtegies. |
mitesh2patel | 0:e1a0471e5ffb | 9 | */ |
mitesh2patel | 0:e1a0471e5ffb | 10 | class HTTPFields : public HTTPHandler { |
mitesh2patel | 0:e1a0471e5ffb | 11 | public: |
mitesh2patel | 0:e1a0471e5ffb | 12 | /** |
mitesh2patel | 0:e1a0471e5ffb | 13 | * Create new HTTPFields |
mitesh2patel | 0:e1a0471e5ffb | 14 | * @param prefix The prefix path on witch we will execute the Handler. Means add the fields. |
mitesh2patel | 0:e1a0471e5ffb | 15 | * @param fields The Fields wicht are added to all Handlers with the same prefix and which are added after this one. |
mitesh2patel | 0:e1a0471e5ffb | 16 | */ |
mitesh2patel | 0:e1a0471e5ffb | 17 | HTTPFields(const char *prefix, const char *fields) : HTTPHandler(prefix) { _fields = fields; } |
mitesh2patel | 0:e1a0471e5ffb | 18 | HTTPFields(HTTPServer *server, const char *prefix, const char *fields) : HTTPHandler(prefix) { _fields = fields; server->addHandler(this); } |
mitesh2patel | 0:e1a0471e5ffb | 19 | |
mitesh2patel | 0:e1a0471e5ffb | 20 | private: |
mitesh2patel | 0:e1a0471e5ffb | 21 | /** |
mitesh2patel | 0:e1a0471e5ffb | 22 | * The Action methon should work on a Connection. |
mitesh2patel | 0:e1a0471e5ffb | 23 | * If the result is HTTP_AddFields the Server will know that we modified the connection header. |
mitesh2patel | 0:e1a0471e5ffb | 24 | * If the result is HTTP_Deliver the server will use this object to anwere the request. |
mitesh2patel | 0:e1a0471e5ffb | 25 | * |
mitesh2patel | 0:e1a0471e5ffb | 26 | * In this case we add new fields to the header. |
mitesh2patel | 0:e1a0471e5ffb | 27 | */ |
mitesh2patel | 0:e1a0471e5ffb | 28 | virtual HTTPHandle action(HTTPConnection *con) const { |
mitesh2patel | 0:e1a0471e5ffb | 29 | char *old = (char *)con->getHeaderFields(); |
mitesh2patel | 0:e1a0471e5ffb | 30 | int oldlen = strlen(old); |
mitesh2patel | 0:e1a0471e5ffb | 31 | int atrlen = strlen(_fields); |
mitesh2patel | 0:e1a0471e5ffb | 32 | char *fields = new char[atrlen+oldlen+3]; |
mitesh2patel | 0:e1a0471e5ffb | 33 | strcpy(fields,old); |
mitesh2patel | 0:e1a0471e5ffb | 34 | fields[oldlen+0] = '\r'; |
mitesh2patel | 0:e1a0471e5ffb | 35 | fields[oldlen+1] = '\n'; |
mitesh2patel | 0:e1a0471e5ffb | 36 | strcpy(&fields[oldlen+2], _fields); |
mitesh2patel | 0:e1a0471e5ffb | 37 | fields[atrlen+2+oldlen] = '\0'; |
mitesh2patel | 0:e1a0471e5ffb | 38 | con->setHeaderFields(fields); |
mitesh2patel | 0:e1a0471e5ffb | 39 | if(*old) { |
mitesh2patel | 0:e1a0471e5ffb | 40 | delete old; |
mitesh2patel | 0:e1a0471e5ffb | 41 | } |
mitesh2patel | 0:e1a0471e5ffb | 42 | return HTTP_AddFields; |
mitesh2patel | 0:e1a0471e5ffb | 43 | } |
mitesh2patel | 0:e1a0471e5ffb | 44 | |
mitesh2patel | 0:e1a0471e5ffb | 45 | const char *_fields; |
mitesh2patel | 0:e1a0471e5ffb | 46 | }; |
mitesh2patel | 0:e1a0471e5ffb | 47 | |
mitesh2patel | 0:e1a0471e5ffb | 48 | #endif |
mitesh2patel | 0:e1a0471e5ffb | 49 |