apache::testrequest.3
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 3 代码 · 共 693 行 · 第 1/2 页
3
693 行
just as \f(CW\*(C`GET_BODY\*(C'\fR would..PP\fI\s-1GET_OK\s0\fR.IX Subsection "GET_OK".PPA shortcut function for \f(CW\*(C`GET($uri)\->is_success\*(C'\fR..PP\fI\s-1GET_RC\s0\fR.IX Subsection "GET_RC".PPA shortcut function for \f(CW\*(C`GET($uri)\->code\*(C'\fR..PP\fI\s-1GET_HEAD\s0\fR.IX Subsection "GET_HEAD".PPThrows out the content of the request, and returns the stringrepresentation of the request. Since the body has been thrown out, therepresentation will consist solely of the headers. Furthermore,\&\f(CW\*(C`GET_HEAD\*(C'\fR inserts a \*(L"#\*(R" at the beginning of each line of the returnstring, so that the contents are suitable for printing to \s-1STDERR\s0during your tests without interfering with the workings of\&\f(CW\*(C`Test::Harness\*(C'\fR..PP\fI\s-1HEAD\s0\fR.IX Subsection "HEAD".PP.Vb 1\& my $res = HEAD $uri;.Ve.PPSends a \s-1HEAD\s0 request to the Apache test server. Returns an\&\f(CW\*(C`HTTP::Response\*(C'\fR object..PP\fI\s-1HEAD_STR\s0\fR.IX Subsection "HEAD_STR".PPA shortcut function for \f(CW\*(C`HEAD($uri)\->as_string\*(C'\fR..PP\fI\s-1HEAD_BODY\s0\fR.IX Subsection "HEAD_BODY".PPA shortcut function for \f(CW\*(C`HEAD($uri)\->content\*(C'\fR. Of course, thismeans that it will likely return nothing..PP\fI\s-1HEAD_BODY_ASSERT\s0\fR.IX Subsection "HEAD_BODY_ASSERT".PPUse this function when your test is outputting content that you needto check, and you want to make sure that the request was successfulbefore comparing the contents of the request. If the request wasunsuccessful, \f(CW\*(C`HEAD_BODY_ASSERT\*(C'\fR will return an errormessage. Otherwise it will simply return the content of the requestjust as \f(CW\*(C`HEAD_BODY\*(C'\fR would..PP\fI\s-1HEAD_OK\s0\fR.IX Subsection "HEAD_OK".PPA shortcut function for \f(CW\*(C`GET($uri)\->is_success\*(C'\fR..PP\fI\s-1HEAD_RC\s0\fR.IX Subsection "HEAD_RC".PPA shortcut function for \f(CW\*(C`GET($uri)\->code\*(C'\fR..PP\fI\s-1HEAD_HEAD\s0\fR.IX Subsection "HEAD_HEAD".PPThrows out the content of the request, and returns the stringrepresentation of the request. Since the body has been thrown out, therepresentation will consist solely of the headers. Furthermore,\&\f(CW\*(C`GET_HEAD\*(C'\fR inserts a \*(L"#\*(R" at the beginning of each line of the returnstring, so that the contents are suitable for printing to \s-1STDERR\s0during your tests without interfering with the workings of\&\f(CW\*(C`Test::Harness\*(C'\fR..PP\fI\s-1PUT\s0\fR.IX Subsection "PUT".PP.Vb 1\& my $res = PUT $uri;.Ve.PPSends a simple \s-1PUT\s0 request to the Apache test server. Returns an\&\f(CW\*(C`HTTP::Response\*(C'\fR object..PP\fI\s-1PUT_STR\s0\fR.IX Subsection "PUT_STR".PPA shortcut function for \f(CW\*(C`PUT($uri)\->as_string\*(C'\fR..PP\fI\s-1PUT_BODY\s0\fR.IX Subsection "PUT_BODY".PPA shortcut function for \f(CW\*(C`PUT($uri)\->content\*(C'\fR..PP\fI\s-1PUT_BODY_ASSERT\s0\fR.IX Subsection "PUT_BODY_ASSERT".PPUse this function when your test is outputting content that you needto check, and you want to make sure that the request was successfulbefore comparing the contents of the request. If the request wasunsuccessful, \f(CW\*(C`PUT_BODY_ASSERT\*(C'\fR will return an errormessage. Otherwise it will simply return the content of the requestjust as \f(CW\*(C`PUT_BODY\*(C'\fR would..PP\fI\s-1PUT_OK\s0\fR.IX Subsection "PUT_OK".PPA shortcut function for \f(CW\*(C`PUT($uri)\->is_success\*(C'\fR..PP\fI\s-1PUT_RC\s0\fR.IX Subsection "PUT_RC".PPA shortcut function for \f(CW\*(C`PUT($uri)\->code\*(C'\fR..PP\fI\s-1PUT_HEAD\s0\fR.IX Subsection "PUT_HEAD".PPThrows out the content of the request, and returns the stringrepresentation of the request. Since the body has been thrown out, therepresentation will consist solely of the headers. Furthermore,\&\f(CW\*(C`PUT_HEAD\*(C'\fR inserts a \*(L"#\*(R" at the beginning of each line of the returnstring, so that the contents are suitable for printing to \s-1STDERR\s0during your tests without interfering with the workings of\&\f(CW\*(C`Test::Harness\*(C'\fR..PP\fI\s-1POST\s0\fR.IX Subsection "POST".PP.Vb 1\& my $res = POST $uri, [ arg => $val, arg2 => $val ];.Ve.PPSends a \s-1POST\s0 request to the Apache test server and returns an\&\f(CW\*(C`HTTP::Response\*(C'\fR object. An array reference of parameters passed asthe second argument will be submitted to the Apache test server as the\&\s-1POST\s0 content. Parameters corresponding to those documented inOptional Parameters can follow the optional array reference of parameters, or after\&\f(CW$uri\fR..PPTo upload a chunk of data, simply use:.PP.Vb 1\& my $res = POST $uri, content => $data;.Ve.PP\fI\s-1POST_STR\s0\fR.IX Subsection "POST_STR".PPA shortcut function for \f(CW\*(C`POST($uri, @args)\->content\*(C'\fR..PP\fI\s-1POST_BODY\s0\fR.IX Subsection "POST_BODY".PPA shortcut function for \f(CW\*(C`POST($uri, @args)\->content\*(C'\fR..PP\fI\s-1POST_BODY_ASSERT\s0\fR.IX Subsection "POST_BODY_ASSERT".PPUse this function when your test is outputting content that you needto check, and you want to make sure that the request was successfulbefore comparing the contents of the request. If the request wasunsuccessful, \f(CW\*(C`POST_BODY_ASSERT\*(C'\fR will return an errormessage. Otherwise it will simply return the content of the requestjust as \f(CW\*(C`POST_BODY\*(C'\fR would..PP\fI\s-1POST_OK\s0\fR.IX Subsection "POST_OK".PPA shortcut function for \f(CW\*(C`POST($uri, @args)\->is_success\*(C'\fR..PP\fI\s-1POST_RC\s0\fR.IX Subsection "POST_RC".PPA shortcut function for \f(CW\*(C`POST($uri, @args)\->code\*(C'\fR..PP\fI\s-1POST_HEAD\s0\fR.IX Subsection "POST_HEAD".PPThrows out the content of the request, and returns the stringrepresentation of the request. Since the body has been thrown out, therepresentation will consist solely of the headers. Furthermore,\&\f(CW\*(C`POST_HEAD\*(C'\fR inserts a \*(L"#\*(R" at the beginning of each line of the returnstring, so that the contents are suitable for printing to \s-1STDERR\s0during your tests without interfering with the workings of\&\f(CW\*(C`Test::Harness\*(C'\fR..PP\fI\s-1UPLOAD\s0\fR.IX Subsection "UPLOAD".PP.Vb 1\& my $res = UPLOAD $uri, \e@args, filename => $filename;.Ve.PPSends a request to the Apache test server that includes an uploadedfile. Other \s-1POST\s0 parameters can be passed as a second argument as anarray reference..PP\&\f(CW\*(C`Apache::TestRequest\*(C'\fR will read in the contents of the file named viathe \f(CW\*(C`filename\*(C'\fR parameter for submission to the server. If you'drather, you can submit use the \f(CW\*(C`content\*(C'\fR parameter instead of\&\f(CW\*(C`filename\*(C'\fR, and its value will be submitted to the Apache server asfile contents:.PP.Vb 1\& my $res = UPLOAD $uri, undef, content => "This is file content";.Ve.PPThe name of the file sent to the server will simply be \*(L"b\*(R". Note thatin this case, you cannot pass other \s-1POST\s0 arguments to \f(CW\*(C`UPLOAD()\*(C'\fR \*(--they would be ignored..PP\fI\s-1UPLOAD_BODY\s0\fR.IX Subsection "UPLOAD_BODY".PPA shortcut function for \f(CW\*(C`UPLOAD($uri, @params)\->content\*(C'\fR..PP\fI\s-1UPLOAD_BODY_ASSERT\s0\fR.IX Subsection "UPLOAD_BODY_ASSERT".PPUse this function when your test is outputting content that you needto check, and you want to make sure that the request was successfulbefore comparing the contents of the request. If the request wasunsuccessful, \f(CW\*(C`UPLOAD_BODY_ASSERT\*(C'\fR will return an errormessage. Otherwise it will simply return the content of the requestjust as \f(CW\*(C`UPLOAD_BODY\*(C'\fR would..PP\fI\s-1OPTIONS\s0\fR.IX Subsection "OPTIONS".PP.Vb 1\& my $res = OPTIONS $uri;.Ve.PPSends an \f(CW\*(C`OPTIONS\*(C'\fR request to the Apache test server. Returns an\&\f(CW\*(C`HTTP::Response\*(C'\fR object with the \fIAllow\fR header, indicating whichmethods the server supports. Possible methods include \f(CW\*(C`OPTIONS\*(C'\fR,\&\f(CW\*(C`GET\*(C'\fR, \f(CW\*(C`HEAD\*(C'\fR and \f(CW\*(C`POST\*(C'\fR. This function thus can be useful fortesting what options the Apache server supports. Consult the \s-1HTTPD\s0 1.1specification, section 9.2, at\&\fIhttp://www.faqs.org/rfcs/rfc2616.html\fR for more information..Sh "\s-1URL\s0 Manipulation Functions".IX Subsection "URL Manipulation Functions"\&\f(CW\*(C`Apache::TestRequest\*(C'\fR also includes a few helper functions to aid inthe creation of urls used in the functions above..PP\fI\f(CI\*(C`module2path\*(C'\fI\fR.IX Subsection "module2path".PP.Vb 1\& $path = Apache::TestRequest::module2path($module_name);.Ve.PPConvert a module name to a path, safe for use in the various requestmethods above. e.g. \f(CW\*(C`::\*(C'\fR can't be used in URLs on win32. For example:.PP.Vb 1\& $path = Apache::TestRequest::module2path(\*(AqFoo::Bar\*(Aq);.Ve.PPreturns:.PP.Vb 1\& /Foo_\|_Bar.Ve.PP\fI\f(CI\*(C`module2url\*(C'\fI\fR.IX Subsection "module2url".PP.Vb 2\& $url = Apache::TestRequest::module2url($module);\& $url = Apache::TestRequest::module2url($module, \e%options);.Ve.PPConvert a module name to a full \s-1URL\s0 including the currentconfigurations \f(CW\*(C`hostname:port\*(C'\fR and sets \f(CW\*(C`module\*(C'\fR accordingly..PP.Vb 1\& $url = Apache::TestRequest::module2url(\*(AqFoo::Bar\*(Aq);.Ve.PPreturns:.PP.Vb 1\& http://$hostname:$port/Foo_\|_Bar.Ve.PPThe default scheme used is \f(CW\*(C`http\*(C'\fR. You can override this by passingyour preferred scheme into an optional second param. For example:.PP.Vb 2\& $module = \*(AqMyTestModule::TestHandler\*(Aq;\& $url = Apache::TestRequest::module2url($module, {scheme => \*(Aqhttps\*(Aq});.Ve.PPreturns:.PP.Vb 1\& https://$hostname:$port/MyTestModule_\|_TestHandler.Ve.PPYou may also override the default path with a path of your own:.PP.Vb 2\& $module = \*(AqMyTestModule::TestHandler\*(Aq;\& $url = Apache::TestRequest::module2url($module, {path => \*(Aq/foo\*(Aq});.Ve.PPreturns:.PP.Vb 1\& http://$hostname:$port/foo.Ve.SH "ENVIRONMENT VARIABLES".IX Header "ENVIRONMENT VARIABLES"The following environment variables can affect the behavior of\&\f(CW\*(C`Apache::TestRequest\*(C'\fR:.IP "\s-1APACHE_TEST_PRETEND_NO_LWP\s0" 4.IX Item "APACHE_TEST_PRETEND_NO_LWP"If the environment variable \f(CW\*(C`APACHE_TEST_PRETEND_NO_LWP\*(C'\fR is set to atrue value, \f(CW\*(C`Apache::TestRequest\*(C'\fR will pretend that \s-1LWP\s0 is notavailable so one can test whether the test suite will survive on asystem which doesn't have libwww-perl installed..IP "\s-1APACHE_TEST_HTTP_09_OK\s0" 4.IX Item "APACHE_TEST_HTTP_09_OK"If the environment variable \f(CW\*(C`APACHE_TEST_HTTP_09_OK\*(C'\fR is set to atrue value, \f(CW\*(C`Apache::TestRequest\*(C'\fR will allow \s-1HTTP/0\s0.9 responsesfrom the server to proceed. The default behavior is to die ifthe response protocol is not either \s-1HTTP/1\s0.0 or \s-1HTTP/1\s0.1..SH "SEE ALSO".IX Header "SEE ALSO"Apache::Test is the main Apache testing module. Use itto set up your tests, create a plan, and to ensure that you have theApache version and modules you need..PPUse Apache::TestMM in your \fIMakefile.PL\fR to set upyour distribution for testing..SH "AUTHOR".IX Header "AUTHOR"Doug MacEachern with contributions from Geoffrey Young, PhilippeM. Chiasson, Stas Bekman and others. Documentation by David Wheeler..PPQuestions can be asked at the test-dev <at> httpd.apache.org list. Formore information see: \fIhttp://httpd.apache.org/test/\fR and\&\fIhttp://perl.apache.org/docs/general/testing/testing.html\fR.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?