#1 2016-07-21 19:10:15

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Add HTML_FOUND (302 Found), HTML_SEEOTHER (303 See Other) redirections

Hi @ab,

To increase user experience in SPA web applications, would you be so kind to extend supported redirection with 302 and 303 codes in mORMotMVC.pas line 1413.

Current version:

procedure TMVCRendererAbstract.ExecuteCommand(aMethodIndex: integer);
...
        if (action.ReturnedStatus=HTML_TEMPORARYREDIRECT) or
           (action.ReturnedStatus=HTML_MOVEDPERMANENTLY) then

Suggested version:

        if (action.ReturnedStatus=HTML_TEMPORARYREDIRECT) or
           (action.ReturnedStatus=HTML_FOUND) or
           (action.ReturnedStatus=HTML_SEEOTHER) or
           (action.ReturnedStatus=HTML_MOVEDPERMANENTLY) then

This is required to handle 302 or 303 POST requests during sending form data to server.
Following this two type of redirect specs & usage history - user-agents should/must change POST method to GET during redirection.
Current 307 redirect keep send POST method on page refresh by user-agent.

This change improve your 30 - MVC Server sample too.
The current behavior: if I press Ctrl+F5 after successful login the browser will show popup message with POST repeat.
But if you add this to lines and change TBlogApplication.Login to return 302 (or more correct 303) the browser (user-agent) will replace POST to GET under the hood and all page refreshes after blog login will not impact the user.

P.S.
Why HTML_FOUND but not HTTP_FOUND?
Isn't it an abstraction leak (low level HTTP response codes named HTML* prefixes, even if we didn't return html, but jpeg or REST json for example)?

Offline

#2 2016-07-27 11:00:24

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Re: Add HTML_FOUND (302 Found), HTML_SEEOTHER (303 See Other) redirections

Hi @ab, any news here?
Do you need a fossil fix from my side?

Offline

#3 2016-07-27 14:51:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Add HTML_FOUND (302 Found), HTML_SEEOTHER (303 See Other) redirections

Please check http://synopse.info/fossil/info/047a6bf08b

Naming HTML_* constants is a real inconsistency.
I've renamed all those constants as HTTP_*.
See http://synopse.info/fossil/info/6064a072aa

This is a breaking change in existing user code.
But may be easy to fix on your projects side.

Offline

#4 2016-07-27 15:50:43

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Re: Add HTML_FOUND (302 Found), HTML_SEEOTHER (303 See Other) redirections

Great, thanks!

Offline

Board footer

Powered by FluxBB