<commit_before>/* http_defs.cc
   <NAME>, 01 September 2015

   Implementation of http definitions
*/

#include <iomanip>
#include <iostream>

#include <pistache/common.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#include <pistache/thirdparty/date.h>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <pistache/http_defs.h>

namespace Pistache {
namespace Http {

namespace {
using time_point = FullDate::time_point;

bool parse_RFC_1123(const std::string &s, time_point &tp) {
  std::istringstream in{s};
  in >> date::parse("%a, %d %b %Y %T %Z", tp);
  return !in.fail();
}

bool parse_RFC_850(const std::string &s, time_point &tp) {
  std::istringstream in{s};
  in >> date::parse("%a, %d-%b-%y %T %Z", tp);
  return !in.fail();
}

bool parse_asctime(const std::string &s, time_point &tp) {
  std::istringstream in{s};
  in >> date::parse("%a %b %d %T %Y", tp);
  return !in.fail();
}

} // anonymous namespace

CacheDirective::CacheDirective(Directive directive) : directive_(), data() {
  init(directive, std::chrono::seconds(0));
}

CacheDirective::CacheDirective(Directive directive, std::chrono::seconds delta)
    : directive_(), data() {
  init(directive, delta);
}

std::chrono::seconds CacheDirective::delta() const {
  switch (directive_) {
  case MaxAge:
    return std::chrono::seconds(data.maxAge);
  case SMaxAge:<commit_msg>Fix parse_RFC_850() The function was identical to parse_RFC_1123(), and the worst thing is that tests with CMake weren't failing, while running them with Meson revealed the issue.<commit_after>/* http_defs.cc
   <NAME>, 01 September 2015

   Implementation of http definitions
*/

#include <iomanip>
#include <iostream>

#include <pistache/common.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#include <pistache/thirdparty/date.h>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <pistache/http_defs.h>

namespace Pistache {
namespace Http {

namespace {
using time_point = FullDate::time_point;

bool parse_RFC_1123(const std::string &s, time_point &tp) {
  std::istringstream in{s};
  in >> date::parse("%a, %d %b %Y %T %Z", tp);
  return !in.fail();
}

bool parse_RFC_850(const std::string &s, time_point &tp) {
  std::istringstream in{s};
  in >> date::parse("%A, %d-%b-%y %T %Z", tp);
  return !in.fail();
}

bool parse_asctime(const std::string &s, time_point &tp) {
  std::istringstream in{s};
  in >> date::parse("%a %b %d %T %Y", tp);
  return !in.fail();
}

} // anonymous namespace

CacheDirective::CacheDirective(Directive directive) : directive_(), data() {
  init(directive, std::chrono::seconds(0));
}

CacheDirective::CacheDirective(Directive directive, std::chrono::seconds delta)
    : directive_(), data() {
  init(directive, delta);
}

std::chrono::seconds CacheDirective::delta() const {
  switch (directive_) {
  case MaxAge:
    return std::chrono::seconds(data.maxAge);
  case SMaxAge:
{'fraction_non_alphanumeric': 0.15436241610738255, 'fraction_numerical': 0.01174496644295302, 'mean_word_length': 5.342553191489362, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6476396', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1051, 'n_words': 275}