Advertisement
GodlyPacketz

http_processor.h

Aug 13th, 2022
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <stdint.h>
  4.  
  5. #include "../util.h"
  6.  
  7. enum {
  8.     HTTP_METHOD_GET,
  9.     HTTP_METHOD_POST,
  10.     HTTP_METHOD_HEAD
  11. };
  12.  
  13. struct http_header_t
  14. {
  15.     char id[64];
  16.     char value[512];
  17. };
  18.  
  19. struct http_connection_t
  20. {
  21.     char host[128];
  22.     char **cookies;
  23.     int cookies_num;
  24. };
  25.  
  26. struct http_request_t
  27. {
  28.     struct http_connection_t *conn;
  29.     struct http_header_t **headers;
  30.     int headers_num;
  31.     int fd;
  32.     char path[256];
  33.     uint8_t method;
  34. };
  35.  
  36. struct http_request_resp_t
  37. {
  38.     int status;
  39.     char *text_resp;
  40.     int text_resp_len;
  41. };
  42.  
  43. struct http_connection_t *http_proc_create_conn(char *host);
  44. void http_proc_destroy_conn(struct http_connection_t *conn);//call when ur done running http requests on target
  45. struct http_request_t *http_proc_create_request(struct http_connection_t *conn, uint8_t method, int fd, char *path);
  46. void http_proc_destroy_request(struct http_request_t *req);//call every time request is sent!
  47. void http_proc_req_addhdr(struct http_request_t *req, char *id, char *value);
  48. void http_proc_req_send(struct http_request_t *req, char *data);
  49. struct http_request_resp_t *http_proc_req_parse(struct http_connection_t *conn, char *buffer, int buffer_len);// remeber to free return value!
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement