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 #871 (closed defect: wontfix)

Opened 13 years ago

Last modified 12 years ago

params for get and post behave differently

Reported by: jvanasco@… Owned by: anonymous
Priority: normal Milestone: 1.0
Component: CherryPy Version: 0.9a5
Severity: normal Keywords:
Cc:

Description

GET and POST data are not available to the exposed method using the same ruleset.

I'm not sure if this is a cherrypy issue or a tg issue , as this seems to affect items in cherrypy.request.params as well

Instead of writing about it, let me just illustrate

given:

class Root(controllers.RootController):
   test = TestController()

class TestController(controllers.Controller):
   @expose()

   def index(self, **kw):
      return dict( kw )

case:

GET /test/?a=b

yields

  kw = { 'a':'b' }

case:

GET /test?a=b

yields

kw = { 'a':'b' }

case

POST /test
c = d

yields

kw = {}

case

POST /test/
c = d

yields

kw = {'c':'d'}

case

POST /test?a=b
c = d

yields

kw = {'a':'b'}

case

POST /test/?a=b
c = d

yields

kw = {'a':'b','c':'d'}

Change History

comment:1 Changed 13 years ago by alberto

I'm pretty sure this is a CherryPy? issue and there's no way that I'm aware of to distinguish them. You can always look at cherrypy.request.method to see if the request was a POST or a GET, but no way is provided to discern the POST params from the urlencoded ones at the url.

Again, this is AFAIK, I'd be gladly proven wrong. Anyway, this has been brought up a couple of times already so I'm sure the CP team will accept a patch that provides this functionallity.

Alberto

comment:2 Changed 13 years ago by jorge.vargas

  • Component changed from TurboGears to CherryPy
  • Milestone set to 1.0

need to identify a way to replicate and push it to the cherrypy folks.

comment:3 Changed 13 years ago by fumanchu@…

This behavior is (somewhat) by design. When either GET or POST are handled by an index method, and the URL is missing the trailing slash, CherryPy? by default does an HTTP redirect (302 or 303) to the same URL with the trailing slash. As  http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html says, there's no cross-browser way to get the behavior we really want (which would be a 301), so we fake it with 303/302.

Because this has its drawbacks and corner cases (as you've noticed), CP 3 includes the ability to turn off the 'automatic' redirection, using tools.trailing_slash.on = False.

Some environments with a strict subset of browsers could choose to use 301 (and the trailing_slash tool should probably provide that option), but I'd recommend closing this ticket as "hopeless".

comment:4 Changed 13 years ago by godoy

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

There's no "hopeless", but I'll use "wontfix", since you're one of CP's developers, you know this much better than we do and this is a bug filed against CP. ;-) Thanks for your help.

Note: See TracTickets for help on using tickets.