For PETEY
Dependencies: mbed EthernetNetIf
TinyHTTP.h@2:764ecec3dc59, 2011-07-28 (annotated)
- Committer:
- okini3939
- Date:
- Thu Jul 28 16:35:09 2011 +0000
- Revision:
- 2:764ecec3dc59
- Parent:
- 0:f2bf5f966801
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:f2bf5f966801 | 1 | /* |
okini3939 | 0:f2bf5f966801 | 2 | * mbed Tiny HTTP Client |
okini3939 | 0:f2bf5f966801 | 3 | * Copyright (c) 2011 Hiroshi Suga |
okini3939 | 0:f2bf5f966801 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
okini3939 | 0:f2bf5f966801 | 5 | */ |
okini3939 | 0:f2bf5f966801 | 6 | |
okini3939 | 0:f2bf5f966801 | 7 | /** @file |
okini3939 | 0:f2bf5f966801 | 8 | * @brief Tiny HTTP Client |
okini3939 | 0:f2bf5f966801 | 9 | */ |
okini3939 | 0:f2bf5f966801 | 10 | |
okini3939 | 0:f2bf5f966801 | 11 | #ifndef TinyHTTP_h |
okini3939 | 0:f2bf5f966801 | 12 | #define TinyHTTP_h |
okini3939 | 0:f2bf5f966801 | 13 | |
okini3939 | 0:f2bf5f966801 | 14 | #define DEBUG |
okini3939 | 0:f2bf5f966801 | 15 | |
okini3939 | 0:f2bf5f966801 | 16 | #define HTTP_PORT 80 |
okini3939 | 0:f2bf5f966801 | 17 | #define HTTP_TIMEOUT 15000 // ms |
okini3939 | 0:f2bf5f966801 | 18 | |
okini3939 | 0:f2bf5f966801 | 19 | #define METHOD_GET 0 |
okini3939 | 0:f2bf5f966801 | 20 | #define METHOD_POST 1 |
okini3939 | 0:f2bf5f966801 | 21 | |
okini3939 | 0:f2bf5f966801 | 22 | /** send http request |
okini3939 | 0:f2bf5f966801 | 23 | * @param method METHOD_GET or METHOD_POST |
okini3939 | 0:f2bf5f966801 | 24 | * @param host http server |
okini3939 | 0:f2bf5f966801 | 25 | * @param uri URI |
okini3939 | 0:f2bf5f966801 | 26 | * @param head http header (CR+LF) (or NULL) |
okini3939 | 0:f2bf5f966801 | 27 | * @param body POST body (or NULL) |
okini3939 | 0:f2bf5f966801 | 28 | * @return http code, -1:failue |
okini3939 | 0:f2bf5f966801 | 29 | */ |
okini3939 | 0:f2bf5f966801 | 30 | int httpRequest (int method, Host *host, char *uri, char *head, char *body); |
okini3939 | 0:f2bf5f966801 | 31 | |
okini3939 | 2:764ecec3dc59 | 32 | void createauth (char *user, char *pwd, char *buf, int len); |
okini3939 | 2:764ecec3dc59 | 33 | |
okini3939 | 2:764ecec3dc59 | 34 | int base64enc(const char *input, unsigned int length, char *output, int len); |
okini3939 | 2:764ecec3dc59 | 35 | |
okini3939 | 2:764ecec3dc59 | 36 | int urlencode(char *str, char *buf, int len); |
okini3939 | 2:764ecec3dc59 | 37 | |
okini3939 | 0:f2bf5f966801 | 38 | #endif |