<commit_before>package RSP::Extension::HTTPRequest;

use strict;
use warnings;

sub provides {
  my $class = shift;
  my $tx    = shift;

  my $cookies = {};
  if ( $tx->request->cookies ) {
    foreach my $cookie ( @{ $tx->request->cookies } ) {
      my $name  = $cookie->name;
      my $value = $cookie->value->to_string;
      $cookies->{$name} = "$value";
    }
  }
  
  return {
    'request' => {
      'uri'    => $tx->request->url->path->to_string,
      'method' => $tx->request->method,
      'query'  => $tx->request->query_params->to_hash,
      'body'   => $tx->request->body_params->to_hash,
      'headers'=> { map {
        ( $_ => $tx->request->headers->header($_) )
      } $tx->request->headers->names },
      'queryString' => $tx->request->url->query->to_string,
      'cookies' => $cookies
    }  
  };
}

1;<commit_msg>need to keep the content around as well, for apps that use PUTs<commit_after>package RSP::Extension::HTTPRequest;

use strict;
use warnings;

sub provides {
  my $class = shift;
  my $tx    = shift;

  my $cookies = {};
  if ( $tx->request->cookies ) {
    foreach my $cookie ( @{ $tx->request->cookies } ) {
      my $name  = $cookie->name;
      my $value = $cookie->value->to_string;
      $cookies->{$name} = "$value";
    }
  }
  
  return {
    'request' => {
      'uri'    => $tx->request->url->path->to_string,
      'method' => $tx->request->method,
      'query'  => $tx->request->query_params->to_hash,
      'body'   => $tx->request->body_params->to_hash,
      'headers'=> { map {
        ( $_ => $tx->request->headers->header($_) )
      } $tx->request->headers->names },
      'queryString' => $tx->request->url->query->to_string,
      'cookies' => $cookies,
      'content' => $tx->request->body
    }  
  };
}

1;
{'fraction_non_alphanumeric': 0.2067605633802817, 'fraction_numerical': 0.0011267605633802818, 'mean_word_length': 2.537848605577689, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 84, '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': '7535596', 'n_tokens_mistral': 629, 'n_tokens_neox': 625, 'n_words': 111}