NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item11383 for general documentation changes for release 1.1.5. Use Item9693 for docu changes for release 2.0.

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

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Being Worked On Engine Documentation, FoswikiUIRest Main.GilmarSantosJr
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

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 Being Worked On
WaitingFor GilmarSantosJr
Checkins
TargetRelease patch
ReleasedIn n/a
Topic revision: r8 - 01 Nov 2011 - 00:48:48 - GeorgeClark
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads