question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Processing OPTIONS request with query parameters in URL

See original GitHub issue
  • I’m submitting a … [*] bug report [ ] feature request [ ] question about the decisions made in the repository

  • Do you want to request a feature or report a bug? I want to report a bug.

  • What is the current behavior? I use CherryPy as WSGI server to serve my Flask application. When I send OPTIONS request with query parameters, for example http://0.0.0.0/profile?param=1, server returns 404 NOT FOUND. It occurs due to wrong URL processing, query string doesn’t remove from URL in request processing.

That’s behaviour appears after upgrading CherryPy from 11.0.0 to 12.0.0

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a screenshots and logs of the problem.
  • CherryPy 12.0.0:
andrey@asus-K55N:~$ curl -i -X OPTIONS http://localhost:5000/api/profile/tariffs?monthly=1
HTTP/1.1 404 NOT FOUND
Content-Type: text/html
Content-Length: 233
Access-Control-Allow-Origin: *
Date: Mon, 20 Nov 2017 13:15:34 GMT
Server: 0.0.0.0

andrey@asus-K55N:~$ curl -i -X OPTIONS http://localhost:5000/api/profile/tariffs
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Allow: GET, OPTIONS, HEAD
Access-Control-Allow-Origin: *
Content-Length: 0
Date: Mon, 20 Nov 2017 13:15:37 GMT
Server: 0.0.0.0
  • CherryPy 11.0.0:
andrey@asus-K55N:~$ curl -i -X OPTIONS http://localhost:5000/api/profile/tariffs?monthly=1
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Allow: HEAD, OPTIONS, GET
Access-Control-Allow-Origin: *
Content-Length: 0
Date: Mon, 20 Nov 2017 13:18:55 GMT
Server: 0.0.0.0
  • What is the expected behavior? Query string parameters should be cut off from URL, as it was in CherryPy 11.0.0.

  • What is the motivation / use case for changing the behavior? Properly processing of OPTIONS requests

  • Please tell us about your environment:

  • Cheroot version: 5.9.1
  • CherryPy version: 12.0.0
  • Python version: 3.5.4
  • OS: Kubuntu 16.04 LTS
  • Browser: [all ]

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:38 (24 by maintainers)

github_iconTop GitHub Comments

2reactions
mantheycommented, Dec 8, 2017

Here is a simple example showing my issue:

import cherrypy

class First(object):
    exposed = True

    def GET(self, *args, **kwargs):
        return 'Did first get\n'

class Second(object):
    exposed = True

    def GET(self, *args, **kwargs):
        return 'Did second get\n'

    def OPTIONS(self, *args, **kwargs):
        return 'Did second options\n'

config = {
    '/': {
        'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
    },
    '/test': {
        'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
    },
}

Root = First()
Root.test = Second()
cherrypy.tree.mount(Root, '/', config)
cherrypy.engine.start()
cherrypy.engine.block()

If you curl "http://127.0.0.1:8080/test" -X GET, you see “Did second get”. If you curl "http://127.0.0.1:8080/test?key=value" -X GET, you see “Did second get”. If you curl "http://127.0.0.1:8080/test" -X OPTIONS, you see “Did second options” If you curl "http://127.0.0.1:8080/test?key=value" -X OPTIONS, you get a 405 error (this is different than in versions before 11.1 where it prints “Did second options”.

1reaction
Rhistinacommented, Feb 19, 2019

Hello. I’m trying to upgrade to cherrypy 18.1.0… Is the only viable workaround to use version 11?

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Beginner's Guide to URL Parameters - Semrush
In this comprehensive guide, we explore the ins and outs of URL parameters. Discover now how to use query strings without hurting your ......
Read more >
Working with Query Parameters in Rest Assured | REST API
What are query parameters in rest assured and query strings in an URL? How to write and execute tests by adding query parameters...
Read more >
Query Parameters - Branch.io
Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are...
Read more >
Best practice for sending query parameters in a GET request?
People can't easily change the options to adjust your query. Having it in the url is simple to just modify and reload with...
Read more >
Interactive guide to API Request Parameters - RapidAPI
In simple terms, API request parameters are options that can be passed ... The blinking part of the Request URL below is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found