1 /*
2  * Copyright (c) 2023, Emna Rekik
3  * Copyright (c) 2023 Nordic Semiconductor ASA
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef HTTP_SERVER_INTERNAL_H_
9 #define HTTP_SERVER_INTERNAL_H_
10 
11 #include <stdbool.h>
12 
13 #include <zephyr/net/http/server.h>
14 #include <zephyr/net/http/service.h>
15 #include <zephyr/net/http/status.h>
16 #include <zephyr/net/http/hpack.h>
17 #include <zephyr/net/http/frame.h>
18 
19 /* HTTP1/HTTP2 state handling */
20 int handle_http_frame_rst_stream(struct http_client_ctx *client);
21 int handle_http_frame_goaway(struct http_client_ctx *client);
22 int handle_http_frame_settings(struct http_client_ctx *client);
23 int handle_http_frame_priority(struct http_client_ctx *client);
24 int handle_http_frame_continuation(struct http_client_ctx *client);
25 int handle_http_frame_window_update(struct http_client_ctx *client);
26 int handle_http_frame_header(struct http_client_ctx *client);
27 int handle_http_frame_headers(struct http_client_ctx *client);
28 int handle_http_frame_data(struct http_client_ctx *client);
29 int handle_http_frame_padding(struct http_client_ctx *client);
30 int handle_http1_request(struct http_client_ctx *client);
31 int handle_http1_to_http2_upgrade(struct http_client_ctx *client);
32 int handle_http1_to_websocket_upgrade(struct http_client_ctx *client);
33 void http_server_release_client(struct http_client_ctx *client);
34 
35 int enter_http1_request(struct http_client_ctx *client);
36 int enter_http2_request(struct http_client_ctx *client);
37 int enter_http_done_state(struct http_client_ctx *client);
38 
39 /* Others */
40 struct http_resource_detail *get_resource_detail(const char *path, int *len, bool is_ws);
41 int http_server_sendall(struct http_client_ctx *client, const void *buf, size_t len);
42 void http_server_get_content_type_from_extension(char *url, char *content_type,
43 						 size_t content_type_size);
44 int http_server_find_file(char *fname, size_t fname_size, size_t *file_size, bool *gzipped);
45 void http_client_timer_restart(struct http_client_ctx *client);
46 
47 /* TODO Could be static, but currently used in tests. */
48 int parse_http_frame_header(struct http_client_ctx *client, const uint8_t *buffer,
49 			    size_t buflen);
50 const char *get_frame_type_name(enum http2_frame_type type);
51 
52 #endif /* HTTP_SERVER_INTERNAL_H_ */
53