You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

http_util.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*-
  2. * Copyright 2019 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef RSPAMD_HTTP_UTIL_H
  17. #define RSPAMD_HTTP_UTIL_H
  18. #include "config.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /**
  23. * Parse HTTP date header and return it as time_t
  24. * @param header HTTP date header
  25. * @param len length of header
  26. * @return time_t or (time_t)-1 in case of error
  27. */
  28. time_t rspamd_http_parse_date (const gchar *header, gsize len);
  29. /**
  30. * Prints HTTP date from `time` to `buf` using standard HTTP date format
  31. * @param buf date buffer
  32. * @param len length of buffer
  33. * @param time time in unix seconds
  34. * @return number of bytes written
  35. */
  36. glong rspamd_http_date_format (gchar *buf, gsize len, time_t time);
  37. /**
  38. * Normalize HTTP path removing dot sequences and repeating '/' symbols as
  39. * per rfc3986#section-5.2
  40. * @param path
  41. * @param len
  42. * @param nlen
  43. */
  44. void rspamd_http_normalize_path_inplace (gchar *path, guint len, guint *nlen);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif