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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /**
  20. * Parse HTTP date header and return it as time_t
  21. * @param header HTTP date header
  22. * @param len length of header
  23. * @return time_t or (time_t)-1 in case of error
  24. */
  25. time_t rspamd_http_parse_date (const gchar *header, gsize len);
  26. /**
  27. * Prints HTTP date from `time` to `buf` using standard HTTP date format
  28. * @param buf date buffer
  29. * @param len length of buffer
  30. * @param time time in unix seconds
  31. * @return number of bytes written
  32. */
  33. glong rspamd_http_date_format (gchar *buf, gsize len, time_t time);
  34. /**
  35. * Normalize HTTP path removing dot sequences and repeating '/' symbols as
  36. * per rfc3986#section-5.2
  37. * @param path
  38. * @param len
  39. * @param nlen
  40. */
  41. void rspamd_http_normalize_path_inplace (gchar *path, guint len, guint *nlen);
  42. #endif