Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #567 (closed defect: wontfix)

Opened 13 years ago

Last modified 12 years ago

GET works, POST doesn't

Reported by: elver.loho@… Owned by: anonymous
Priority: low Milestone:
Component: CherryPy Version: 0.8
Severity: minor Keywords:
Cc:

Description

Basically I'm trying to create a login box. I started off using the GET method, but when I changed to using the POST method, stuff stopped working. Basically now I'm in a situation where by changing the form method from GET to POST simply breaks it.

Relevant template code:

<h1>Log in</h1> <form name="login" method="GET" action="/admin">

<p>Username: <input type="text" name="username" size="20" value=""/></p> <p>Password: <input type="password" name="password" size="20" value=""/></p> <p><input type="submit" value="Log in"/></p>

</form>

Relevant controller code:

class Admin:

@turbogears.expose(html="blogfields.templates.loginwindow") def index(self, username=None, password=None, *args, kw):

print print str(username) + " " + str(password) print str(args) print str(kw) print return dict()

When I use GET, the output on the server console is:

elver password () {}

When I use POST, the output on the server console is:

None None () {}

What the hell am I missing here?

Change History

comment:1 Changed 13 years ago by Stephen Thorne <stephen@…>

(from #323) The problem with POSTs still exists, as the current patch makes the trailing slash 'fixed' for GETs, but accepts both /foo and /foo/ as being the same thing for the purposes of a POST.

I think the best thing to do in the case of a POST is to raise an error if the slash isn't used correctly. Both the programmer and the user have control over GETs, but the programmer is expected to get the POSTs correct.

To illustrate the behaviour I think is more appropriate:

GET /foo will redirect to /foo/

GET /foo/ will render the page

POST /foo will be a 405 Method Not Allowed

POST /foo/ will render the page

comment:2 Changed 13 years ago by tbradshaw

This seems to be a little bit of an inconsistancy with the CherryPy? project. CherryPy? appears to go to great lengths to make the "differences" between POST's and GET's completely transparent to both the user and the developers.

Perhaps the handler for POST /foo would be best served by maintaining the state and forwarding that to POST /foo/ . Is there a reason that this would be undesireable?

comment:3 Changed 13 years ago by tbradshaw

  • Priority changed from high to low
  • Severity changed from blocker to minor

In the short term, this appears to be an issue that could be worked around easily with documentation rather than a high priority blocker. Perhaps a blurb in a FAQ somewhere would be appropriate. Adjusting Priority and Severity.

comment:4 Changed 13 years ago by jorge.vargas

still present? if not please close.

comment:5 Changed 13 years ago by fumanchu@…

Perhaps the handler for POST /foo would be best served by maintaining the state and forwarding that to POST /foo/ . Is there a reason that this would be undesireable?

That's not as easy for POST as it is for GET, at least not when using HTTP redirects (302, 303). The current 'solution' is suboptimal because browser support for the spec is suboptimal and fragmented. See  http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html. As with #871, this ticket should probably be set for the "when Hell freezes over" milestone. ;)

CherryPy 3 allows the developer to completely stop using buggy redirects for trailing-slash issues, and just pass control to the proper handler. Just set tools.trailing_slash.on = False. If you'd like to see this feature backported to CherryPy? 2.2, please open a ticket at  http://www.cherrypy.org.

comment:6 Changed 13 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to wontfix

setting to "when Hell freezes over" milestone.

Note: See TracTickets for help on using tickets.