File: 19_json_body.t

package info (click to toggle)
libdancer-perl 1.3521%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,460 kB
  • sloc: perl: 7,436; xml: 2,211; sh: 54; makefile: 32; sql: 5
file content (26 lines) | stat: -rw-r--r-- 619 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strict;
use warnings;
no warnings 'uninitialized';

use Test::More qw(no_plan);

use HTTP::Headers;

use Dancer::Request;

my $headers = HTTP::Headers->new;
$headers->header('Content-Type' => 'application/json');
$headers->header('Accept' => 'application/json');
my $json_string = '{"json_thing":"whatever"}';
my $request = Dancer::Request->new_for_request(
    PATCH => '/some/url/or/another',
    undef, $json_string, $headers,
    {
        CONTENT_TYPE => 'application/json',
        HTTP_ACCEPT => 'application/json',
        REQUEST_URI => '/some/url/or/another',
    }
);

is($request->body, $json_string);