This question about Developing extensions (plugins skins etc.): Asked

Rest interface - how to use the response object

-- BramVanOosterhout - 04 Jan 2019 I am writing a Import plugin using the rest interface. I would like to generate a well formatted page to show the results of the processing. Essentially a list that shows what happened and the status.

To do that I assume I need to populate the response object. That does provide output, but not what i expect. I expected a properly formatted page with html, head and body tags. But all I get is the text in the response->body.

What am I missing?

I have written a test as follows:
        'testresponse', \&TESTRESPONSE,
        authenticate => 1,  # Set to 0 if handler should be useable by WikiGuest
        validate     => 1,  # Set to 0 to disable StrikeOne CSRF protection
        http_allow => 'GET,POST', # Set to 'GET,POST' to allow use HTTP GET and POST
        description => 'Handler to understand the use of the response object. To be deleted on completion'

      my ( $session, $subject, $verb, $response ) = @_;
use Data::Dump qw(dump);      
        -status =>  200,
        -type => 'text/html',
        -charset => 'text'
    $response->body("Here is my body followed by the Reponse object:\n");
    $response->body("Here is my body followed by the Reponse object:\n".dump($response));

And a test page:
<form method="post" name="testresponse" action="%SCRIPTURL{rest}%/TopicImportExportPlugin/testresponse">
<input type="submit" />

And the result is (view source):
Here is my body followed by the Reponse object:
  body => "Here is my body followed by the Reponse object:\n",
  charset => "text",
  cookies => [
      domain   => "",
      httponly => 1,
      name     => "FOSWIKISID",
      path     => "/",
      secure   => 0,
      value    => ["7cde4e96e05f4814764799195cc243bf"],
    }, "CGI::Cookie"),
  headers => {
    "Content-Length" => 48,
    "Content-Type" => "text/html; charset=text",
    "Status" => 200,
  outputHasStarted => 0,
  status => 200,
}, "Foswiki::Response")

As you can see: No html, head, or body tags. And no head content.

Can I do what I want to do? what am I missing? Thanks in advance for your help.

Is there anyone who can tell? I am still curious.

-- BramVanOosterhout - 07 Apr 2019

QuestionForm edit

Subject Developing extensions (plugins skins etc.)
Version Foswiki 2.1.5
Status Asked
Related Topics
Topic revision: r2 - 07 Apr 2019, BramVanOosterhout - This page was cached on 03 Jun 2020 - 21:20.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy