liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /************************************************************* |
| 2 | Description: |
| 3 | HTTP platform related function implementation. |
| 4 | Author: |
| 5 | LiuBin |
| 6 | Date: |
| 7 | 2020/4/30 14:02:58 |
| 8 | *************************************************************/ |
| 9 | #ifndef _MBTK_HTTP_BASE_H |
| 10 | #define _MBTK_HTTP_BASE_H |
| 11 | |
| 12 | #include <stdio.h> |
| 13 | |
| 14 | #include "mbtk_type.h" |
| 15 | #include "mbtk_log.h" |
| 16 | #include "mbtk_sock2.h" |
| 17 | |
| 18 | /************************************************************* |
| 19 | Public Function Declaration |
| 20 | *************************************************************/ |
| 21 | int mbtk_http_init(); |
| 22 | int mbtk_http_deinit(); |
| 23 | int mbtk_http_open |
| 24 | ( |
| 25 | bool is_ssl, |
| 26 | bool ingnore_cert, |
| 27 | const void *host, |
| 28 | uint16 port |
| 29 | ); |
| 30 | |
| 31 | /*============================================= |
| 32 | FUNCTION |
| 33 | mbtk_http_read |
| 34 | |
| 35 | DESCRIPTION |
| 36 | read content from socket. |
| 37 | |
| 38 | DEPENDENCIES |
| 39 | None |
| 40 | |
| 41 | PARAMETERS |
| 42 | *buf Store read content. |
| 43 | len the length of Content. |
| 44 | timeout Set timeout |
| 45 | |
| 46 | RETURN VALUE |
| 47 | Length of read content |
| 48 | |
| 49 | SIDE EFFECTS |
| 50 | None |
| 51 | =============================================*/ |
| 52 | int mbtk_http_read |
| 53 | ( |
| 54 | int sock_fd, |
| 55 | void *buf, |
| 56 | uint16 len, |
| 57 | int timeout_ms |
| 58 | ); |
| 59 | |
| 60 | #if 0 |
| 61 | int mbtk_http_read_line |
| 62 | ( |
| 63 | FILE *file, |
| 64 | void *buf, |
| 65 | uint16 len |
| 66 | ); |
| 67 | #else |
| 68 | int mbtk_http_read_line |
| 69 | ( |
| 70 | int sock_fd, |
| 71 | void *buf, |
| 72 | uint16 len |
| 73 | ); |
| 74 | #endif |
| 75 | |
| 76 | /*============================================= |
| 77 | FUNCTION |
| 78 | mbtk_http_write |
| 79 | |
| 80 | DESCRIPTION |
| 81 | Write content to socket. |
| 82 | |
| 83 | DEPENDENCIES |
| 84 | None |
| 85 | |
| 86 | PARAMETERS |
| 87 | *buf Content to be transferred |
| 88 | len the length of Content. |
| 89 | |
| 90 | RETURN VALUE |
| 91 | Length of written content |
| 92 | |
| 93 | SIDE EFFECTS |
| 94 | None |
| 95 | =============================================*/ |
| 96 | int mbtk_http_write |
| 97 | ( |
| 98 | int sock_fd, |
| 99 | void *buf, |
| 100 | uint16 len |
| 101 | ); |
| 102 | |
| 103 | /*============================================= |
| 104 | FUNCTION |
| 105 | mbtk_http_close |
| 106 | |
| 107 | DESCRIPTION |
| 108 | close HTTP service. |
| 109 | |
| 110 | DEPENDENCIES |
| 111 | None |
| 112 | |
| 113 | PARAMETERS |
| 114 | *err Error number |
| 115 | |
| 116 | RETURN VALUE |
| 117 | TURE or FALSE |
| 118 | |
| 119 | SIDE EFFECTS |
| 120 | None |
| 121 | =============================================*/ |
| 122 | int mbtk_http_close(int sock_fd); |
| 123 | |
| 124 | #endif /* _MBTK_HTTP_BASE_H */ |