/t/010_core/request-body.t

http://github.com/http-engine/HTTP-Engine · Raku · 27 lines · 22 code · 3 blank · 2 comment · 0 complexity · 1abb6d0b23505446875c98c1afea04a5 MD5 · raw file

  1. use strict;
  2. use warnings;
  3. use Test::More tests => 2;
  4. use t::Utils;
  5. use HTTP::Engine;
  6. use HTTP::Request;
  7. # prepare
  8. my $body = 'foo=bar';
  9. my $req = HTTP::Request->new(
  10. 'POST',
  11. '/',
  12. HTTP::Headers::Fast->new(
  13. 'content-length' => length($body),
  14. 'Content-Type' => 'application/x-www-form-urlencoded',
  15. ),
  16. $body,
  17. );
  18. # do test
  19. run_engine {
  20. my $req = shift;
  21. is $req->raw_body, 'foo=bar';
  22. is_deeply $req->body_params, { foo => 'bar' };
  23. return ok_response;
  24. } $req;