You are here: Foswiki>Tasks Web>Item969 (20 Jun 2015, CrawfordCurrie)Edit Attach

Item969: When rest method returns undef, headers are still printed

pencil
Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release: patch
Applies To: Engine
Component: Documentation, FoswikiUIRest
Branches:
Reported By: EugenMayer
Waiting For:
Last Change By: CrawfordCurrie
When you call a resthandler and return undef, this case is skipping "wirteComplepage" and is expecting you to write headers and content. Actually this is not happening, as in Engine::run the headers are printed anyway ( i mean the headers of Foswiki as if return 1 would have been used )

Iam actually not sure, this is supposed to be that way ( then return undef is completely senseless ) or this was introduced with FSA or i am simply not getting the right idea.

-- EugenMayer - 03 Feb 2009

This is working instead:

sub _restfunction {
    my $session = shift;
 
    $session->{response}->header( -status => "500 Test" );
    $session->{response}->header( -"X-Testing" => "123" );

    return "Hello World";
}

-- OliverKrueger - 03 Feb 2009

From todays irc discussion I learned, that the current behaviour is not wanted. I guess it was introduced with and is related to FSA. Setting this Item so Confirmed.

-- OliverKrueger - 04 Feb 2009

I think this problem was caused by the use of Foswiki::Response::header to implement the extra headers. I replaced that calls by Foswiki::Response::pushHeader and I hope that the only headers returned by restHandler are those two plus the ones the handler defines.

Please check and comment/close this task wink

-- GilmarSantosJr - 04 Feb 2009

Well it seems to work now, but maybe Crawford has other issues. I set him on WaitingFor to have his feedback or close this item. Thank you Gildmar smile

-- EugenMayer - 04 Feb 2009

I don't know which calls you replaced, but I'm a bit concerned that the author of a rest handler may not be able to tell from the documentation what function to call; header or pushHeader. See http://trunk.foswiki.org/System/PerlDoc?module=Foswiki::Response to see what I mean. This needs to be fixed, IMHO.

-- CrawfordCurrie - 05 Feb 2009

I'll improve the documentation wink

-- GilmarSantosJr - 07 Feb 2009

This has been 3 years waiting for doc updates. Anything to report? Has it been corrected by others or is this still an issue?

-- GeorgeClark - 07 Mar 2012

adding Crawford to waiting list

-- SvenDowideit - 08 Mar 2012

Wow! Time went fast! Well, I'm not sure if this fix is still relevant (we had no problems since 2009 related to this missing doc, I think) and there is a work in progress to migrate to PSGI (that leads to replacement of Foswiki::Response). I propose to No action this task.

-- GilmarSantosJr - 10 Mar 2012

Don't rely on the PSGI work; until someone actually carries it through to a release standard, it's not going to happen.

We have spent more time writing in this topic than it would have taken to add a clarifying POD doc to Foswiki::Response. I am not confident to do so myself, which is why I feel we need the doc!

-- CrawfordCurrie - 11 Mar 2012

no problems reported due to missing doc, so quietly dropping this.

-- Main.CrawfordCurrie - 20 Jun 2015 - 08:35

ItemTemplate edit

Summary When rest method returns undef, headers are still printed
ReportedBy EugenMayer
Codebase 1.0.0, trunk
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component Documentation, FoswikiUIRest
Priority Normal
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease patch
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release01x01Checkins
Topic revision: r13 - 20 Jun 2015, CrawfordCurrie - This page was cached on 15 Jan 2020 - 06:19.

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