.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "JSON::RPC::Common::Marshal::HTTP 3pm" .TH JSON::RPC::Common::Marshal::HTTP 3pm "2020-06-23" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JSON::RPC::Common::Marshal::HTTP \- Convert HTTP::Request and HTTP::Response to/from JSON::RPC::Common calls and returns. .SH "VERSION" .IX Header "VERSION" version 0.11 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use JSON::RPC::Common::Marshal::HTTP; \& \& my $m = JSON::RPC::Common::Marshal::HTTP\->new; \& \& my $call = $m\->request_to_call($http_request); \& \& my $res = $call\->call($object); \& \& my $http_response = $m\->result_to_response($res); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This object provides marshalling routines to convert calls and returns to and from HTTP::Request and HTTP::Response objects. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .IP "prefer_get" 4 .IX Item "prefer_get" When encoding a call into a request, prefer \s-1GET.\s0 .Sp Not reccomended. .IP "rest_style_methods" 4 .IX Item "rest_style_methods" When encoding a \s-1GET\s0 request, use \s-1REST\s0 style \s-1URI\s0 formatting (the method is part of the path, not a parameter). .IP "prefer_encoded_get" 4 .IX Item "prefer_encoded_get" When set and a \f(CW\*(C`params\*(C'\fR param exists, decode it as Base 64 encoded \s-1JSON\s0 and use that as the parameters instead of the query parameters. .Sp See . .IP "user_agent" 4 .IX Item "user_agent" Defaults to the marshal object's class name and the JSON::RPC::Common version number. .IP "content_type" 4 .IX Item "content_type" .PD 0 .IP "accept_content_type" 4 .IX Item "accept_content_type" .IP "content_types" 4 .IX Item "content_types" .IP "accept_content_types" 4 .IX Item "accept_content_types" .PD When explicitly set these are the values of the \f(CW\*(C`Content\-Type\*(C'\fR and \f(CW\*(C`Accept\*(C'\fR headers to set. .Sp Otherwise they will default to \f(CW\*(C`application/json\*(C'\fR with calls/returns version 1.0 and 1.1, and \f(CW\*(C`application/json\-rpc\*(C'\fR with 2.0 objects. .IP "expand" 4 .IX Item "expand" Whether or not to use an expander on \f(CW\*(C`GET\*(C'\fR style calls. .IP "expander" 4 .IX Item "expander" An instance of CGI::Expand or a look alike to use for \f(CW\*(C`GET\*(C'\fR parameter expansion. .SH "METHODS" .IX Header "METHODS" .ie n .IP "request_to_call $http_request" 4 .el .IP "request_to_call \f(CW$http_request\fR" 4 .IX Item "request_to_call $http_request" .PD 0 .ie n .IP "post_request_to_call $http_request" 4 .el .IP "post_request_to_call \f(CW$http_request\fR" 4 .IX Item "post_request_to_call $http_request" .ie n .IP "get_request_to_call $http_request" 4 .el .IP "get_request_to_call \f(CW$http_request\fR" 4 .IX Item "get_request_to_call $http_request" .PD Convert an HTTP::Request to a JSON::RPC::Common::Procedure::Call. Depending on what style of request it is, \f(CW\*(C`request_to_call\*(C'\fR will delegate to a variant method. .Sp Get requests call \f(CW\*(C`uri_to_call\*(C'\fR .ie n .IP "uri_to_call $uri" 4 .el .IP "uri_to_call \f(CW$uri\fR" 4 .IX Item "uri_to_call $uri" .PD 0 .ie n .IP "encoded_uri_to_call $uri" 4 .el .IP "encoded_uri_to_call \f(CW$uri\fR" 4 .IX Item "encoded_uri_to_call $uri" .ie n .IP "query_uri_to_call $uri" 4 .el .IP "query_uri_to_call \f(CW$uri\fR" 4 .IX Item "query_uri_to_call $uri" .PD Parse a call from a \s-1GET\s0 request's \s-1URI.\s0 .ie n .IP "result_to_response $return" 4 .el .IP "result_to_response \f(CW$return\fR" 4 .IX Item "result_to_response $return" Convert a JSON::RPC::Common::Procedure::Return to an HTTP::Response. .ie n .IP "write_result_to_response $result, $response" 4 .el .IP "write_result_to_response \f(CW$result\fR, \f(CW$response\fR" 4 .IX Item "write_result_to_response $result, $response" Write the result into an object like Catalyst::Response. .ie n .IP "response_to_result $http_response" 4 .el .IP "response_to_result \f(CW$http_response\fR" 4 .IX Item "response_to_result $http_response" .PD 0 .ie n .IP "response_to_result_success $http_response" 4 .el .IP "response_to_result_success \f(CW$http_response\fR" 4 .IX Item "response_to_result_success $http_response" .ie n .IP "response_to_result_error $http_response" 4 .el .IP "response_to_result_error \f(CW$http_response\fR" 4 .IX Item "response_to_result_error $http_response" .PD Convert an HTTP::Response to a JSON::RPC::Common::Procedure::Return. .Sp A variant is chosen based on \f(CW\*(C`HTTP::Response/is_success\*(C'\fR. .Sp The error handler will ensure that \&\*(L"error\*(R" in JSON::RPC::Common::Procedure::Return is set. .ie n .IP "call_to_request $call, %args" 4 .el .IP "call_to_request \f(CW$call\fR, \f(CW%args\fR" 4 .IX Item "call_to_request $call, %args" .PD 0 .ie n .IP "call_to_get_request $call, %args" 4 .el .IP "call_to_get_request \f(CW$call\fR, \f(CW%args\fR" 4 .IX Item "call_to_get_request $call, %args" .ie n .IP "call_to_post_request $call, %args" 4 .el .IP "call_to_post_request \f(CW$call\fR, \f(CW%args\fR" 4 .IX Item "call_to_post_request $call, %args" .ie n .IP "call_to_uri $call, %args" 4 .el .IP "call_to_uri \f(CW$call\fR, \f(CW%args\fR" 4 .IX Item "call_to_uri $call, %args" .ie n .IP "call_to_encoded_uri $call, %args" 4 .el .IP "call_to_encoded_uri \f(CW$call\fR, \f(CW%args\fR" 4 .IX Item "call_to_encoded_uri $call, %args" .ie n .IP "call_to_query_uri $call, %args" 4 .el .IP "call_to_query_uri \f(CW$call\fR, \f(CW%args\fR" 4 .IX Item "call_to_query_uri $call, %args" .PD Convert a call to a request (or just a \s-1URI\s0 for \s-1GET\s0 requests). .Sp The arguments can contain a \f(CW\*(C`uri\*(C'\fR parameter, which is the base of the request. .Sp With \s-1GET\s0 requests, under \f(CW\*(C`rest_style_methods\*(C'\fR that \s-1URI\s0's path will be appended, and otherwise parameters will just be added. .Sp \&\s-1POST\s0 requests do not cloen and alter the \s-1URI.\s0 .Sp If no \s-1URI\s0 is provided as an argument, \f(CW\*(C`/\*(C'\fR will be used. .Sp The flags \f(CW\*(C`prefer_get\*(C'\fR and \f(CW\*(C`encoded\*(C'\fR can also be passed to \&\f(CW\*(C`call_to_request\*(C'\fR to alter the type of request to be generated. .IP "collapse_query_params" 4 .IX Item "collapse_query_params" .PD 0 .IP "expand_query_params" 4 .IX Item "expand_query_params" .PD Only used for query encoded \s-1GET\s0 requests. If \f(CW\*(C`expand\*(C'\fR is set will cause expansion of the params. Otherwise it's a noop. .Sp Subclass and override to process query params into \s-1RPC\s0 params as necessary. .Sp Note that this is \fB\s-1NOT\s0\fR in any of the JSON-RPC specs. .SH "AUTHOR" .IX Header "AUTHOR" Yuval Kogman .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2014 by Yuval Kogman and others. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.