![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
hattori&ide
TinyHTTP/TinyHTTP.h@0:f77369cabd75, 18 months ago (annotated)
- Committer:
- hattori_atsushi
- Date:
- Sun Dec 18 08:16:01 2022 +0000
- Revision:
- 0:f77369cabd75
hattori
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hattori_atsushi | 0:f77369cabd75 | 1 | /* |
hattori_atsushi | 0:f77369cabd75 | 2 | * mbed Tiny HTTP Client |
hattori_atsushi | 0:f77369cabd75 | 3 | * Copyright (c) 2011 Hiroshi Suga |
hattori_atsushi | 0:f77369cabd75 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
hattori_atsushi | 0:f77369cabd75 | 5 | */ |
hattori_atsushi | 0:f77369cabd75 | 6 | |
hattori_atsushi | 0:f77369cabd75 | 7 | /** @file |
hattori_atsushi | 0:f77369cabd75 | 8 | * @brief Tiny HTTP Client |
hattori_atsushi | 0:f77369cabd75 | 9 | */ |
hattori_atsushi | 0:f77369cabd75 | 10 | |
hattori_atsushi | 0:f77369cabd75 | 11 | #ifndef TinyHTTP_h |
hattori_atsushi | 0:f77369cabd75 | 12 | #define TinyHTTP_h |
hattori_atsushi | 0:f77369cabd75 | 13 | |
hattori_atsushi | 0:f77369cabd75 | 14 | #define DEBUG |
hattori_atsushi | 0:f77369cabd75 | 15 | |
hattori_atsushi | 0:f77369cabd75 | 16 | #define HTTP_PORT 80 |
hattori_atsushi | 0:f77369cabd75 | 17 | #define HTTP_TIMEOUT 15000 // ms |
hattori_atsushi | 0:f77369cabd75 | 18 | |
hattori_atsushi | 0:f77369cabd75 | 19 | #define METHOD_GET 0 |
hattori_atsushi | 0:f77369cabd75 | 20 | #define METHOD_POST 1 |
hattori_atsushi | 0:f77369cabd75 | 21 | |
hattori_atsushi | 0:f77369cabd75 | 22 | /** send http request |
hattori_atsushi | 0:f77369cabd75 | 23 | * @param method METHOD_GET or METHOD_POST |
hattori_atsushi | 0:f77369cabd75 | 24 | * @param host http server |
hattori_atsushi | 0:f77369cabd75 | 25 | * @param uri URI |
hattori_atsushi | 0:f77369cabd75 | 26 | * @param head http header (CR+LF) (or NULL) |
hattori_atsushi | 0:f77369cabd75 | 27 | * @param body POST body (or NULL) |
hattori_atsushi | 0:f77369cabd75 | 28 | * @return http code, -1:failue |
hattori_atsushi | 0:f77369cabd75 | 29 | */ |
hattori_atsushi | 0:f77369cabd75 | 30 | int httpRequest (int method, int sendTime, Host *host, char *uri, char *head, char *body); |
hattori_atsushi | 0:f77369cabd75 | 31 | |
hattori_atsushi | 0:f77369cabd75 | 32 | void createauth (char *user, char *pwd, char *buf, int len); |
hattori_atsushi | 0:f77369cabd75 | 33 | |
hattori_atsushi | 0:f77369cabd75 | 34 | int base64enc(const char *input, unsigned int length, char *output, int len); |
hattori_atsushi | 0:f77369cabd75 | 35 | |
hattori_atsushi | 0:f77369cabd75 | 36 | int urlencode(char *str, char *buf, int len); |
hattori_atsushi | 0:f77369cabd75 | 37 | |
hattori_atsushi | 0:f77369cabd75 | 38 | #endif |