<commit_before>// Copyright (c) 2014-2015 Dr. <NAME> and <NAME>
// Please see LICENSE for license or visit https://github.com/ColinH/PEGTL/

#ifndef PEGTL_CONTRIB_HTTP_HH
#define PEGTL_CONTRIB_HTTP_HH

#include "../rules.hh"
#include "../ascii.hh"
#include "../utf8.hh"
#include "abnf.hh"
#include "uri.hh"

namespace pegtl
{
   namespace http
   {
      // HTTP 1.1 grammar according to RFC 7230.

      // This grammar is a direct PEG translation of the original HTTP grammar.
      // It should be considered experimental -- in case of any issues, in particular
      // missing anchor rules for actions, please contact the developers.

      using namespace abnf;

      using OWS = star< WSP >; // optional whitespace
      using RWS = plus< WSP >; // required whitespace
      using BWS = OWS; // "bad" whitespace

      using obs_text = not_range< 0x00, 0x7F >;
      using obs_fold = seq< CRLF, plus< WSP > >;

      struct tchar : sor< ALPHA, DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {};
      struct token : plus< tchar > {};

      struct field_name : token {};

      struct field_vchar : sor< VCHAR, obs_text > {};
      struct field_content : list_must< field_vchar, plus< WSP > > {};
      struct field_value : star< sor< field_content, obs_fold > > {};

      struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {};

      struct method : token {};

      struct absolute_path : plus< one< '/' >, uri::segment > {};

      struct origin_form : seq< absolute_path, uri::opt_query >  {};
      struct absolute_form : uri::absolute_URI {};
      struct authority_form : uri::authority {};
      struct asterisk_form : one< '*' > {};
<commit_msg>Fix bug in HTTP grammar.<commit_after>// Copyright (c) 2014-2015 Dr. <NAME> and <NAME>
// Please see LICENSE for license or visit https://github.com/ColinH/PEGTL/

#ifndef PEGTL_CONTRIB_HTTP_HH
#define PEGTL_CONTRIB_HTTP_HH

#include "../rules.hh"
#include "../ascii.hh"
#include "../utf8.hh"
#include "abnf.hh"
#include "uri.hh"

namespace pegtl
{
   namespace http
   {
      // HTTP 1.1 grammar according to RFC 7230.

      // This grammar is a direct PEG translation of the original HTTP grammar.
      // It should be considered experimental -- in case of any issues, in particular
      // missing anchor rules for actions, please contact the developers.

      using namespace abnf;

      using OWS = star< WSP >; // optional whitespace
      using RWS = plus< WSP >; // required whitespace
      using BWS = OWS; // "bad" whitespace

      using obs_text = not_range< 0x00, 0x7F >;
      using obs_fold = seq< CRLF, plus< WSP > >;

      struct tchar : sor< ALPHA, DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {};
      struct token : plus< tchar > {};

      struct field_name : token {};

      struct field_vchar : sor< VCHAR, obs_text > {};
      struct field_content : list< field_vchar, plus< WSP > > {};
      struct field_value : star< sor< field_content, obs_fold > > {};

      struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {};

      struct method : token {};

      struct absolute_path : plus< one< '/' >, uri::segment > {};

      struct origin_form : seq< absolute_path, uri::opt_query >  {};
      struct absolute_form : uri::absolute_URI {};
      struct authority_form : uri::authority {};
      struct asterisk_form : one< '*' > {};

{'fraction_non_alphanumeric': 0.15542099192618225, 'fraction_numerical': 0.011534025374855825, 'mean_word_length': 2.803728070175439, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5769196', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1092, 'n_words': 334}