View | Details | Raw Unified | Return to bug 20582
Collapse All | Expand All

(-)a/Koha/App/Plugin/CGIBinKoha.pm (-3 / +30 lines)
Lines 56-65 sub _psgi_env { Link Here
56
56
57
    my $env = $c->req->env;
57
    my $env = $c->req->env;
58
58
59
    my $body = $c->req->body;
60
    $env = {
59
    $env = {
61
        %$env,
60
        %$env,
62
        'psgi.input' => IO::Scalar->new(\$body),
61
        'psgi.input' => $self->_psgi_input($c),
63
        'psgi.errors' => *STDERR,
62
        'psgi.errors' => *STDERR,
64
        REQUEST_METHOD => $c->req->method,
63
        REQUEST_METHOD => $c->req->method,
65
        QUERY_STRING => $c->req->url->query->to_string,
64
        QUERY_STRING => $c->req->url->query->to_string,
Lines 81-84 sub _psgi_env { Link Here
81
    return $env;
80
    return $env;
82
}
81
}
83
82
83
sub _psgi_input {
84
    my ($self, $c) = @_;
85
86
    my $body;
87
88
    my $content = $c->req->content;
89
90
    if ($content->is_multipart) {
91
        # Rebuild the multipart content
92
        $body = '';
93
        my $boundary = $content->boundary;
94
        my $CRLF = "\r\n";
95
        for my $part (@{ $content->parts }) {
96
            $body .= "$CRLF--$boundary$CRLF";
97
            for my $name (@{ $part->headers->names }) {
98
                my $value = $part->headers->header($name);
99
                $body .= "$name: $value$CRLF";
100
            }
101
            $body .= $CRLF;
102
            $body .= $part->asset->slurp;
103
        }
104
        $body .= "$CRLF--$boundary--$CRLF";
105
    } else {
106
        $body = $c->req->body;
107
    }
108
109
    return IO::Scalar->new(\$body);
110
}
111
84
1;
112
1;
85
- 

Return to bug 20582