Code Monkey home page Code Monkey logo

Comments (9)

simonw avatar simonw commented on June 2, 2024

This looks like a Vercel bug:

https://til.simonwillison.net/-/asgi-scope?sql=a%2Bb returns 'query_string': b'sql=a+b'
https://til.simonwillison.net/-/asgi-scope?sql=a+b returns 'query_string': b'sql=a b'

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

And https://til.simonwillison.net/-/asgi-scope?sql=a%252Bb with double-encoding a%252Bb produces 'query_string': b'sql=a%2Bb'.

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

If it's a Vercel bug it will be in this code: https://github.com/vercel/vercel/blob/fcb14fa70e800ff2bf387120ebdaf65affea6661/packages/now-python/now_init.py#L261-L280

            url = urlparse(unquote(payload['path']))
            query = url.query.encode()
            path = url.path

            scope = {
                'server': (headers.get('host', 'lambda'), headers.get('x-forwarded-port', 80)),
                'client': (headers.get(
                    'x-forwarded-for', headers.get(
                        'x-real-ip', payload.get(
                            'true-client-ip', ''))), 0),
                'scheme': headers.get('x-forwarded-proto', 'http'),
                'root_path': '',
                'query_string': query,
                'headers': [[k.lower().encode(), v.encode()] for k, v in headers.items()],
                'type': 'http',
                'http_version': '1.1',
                'method': payload['method'],
                'path': path,
                'raw_path': path.encode(),
            }

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

This commit is useful as it helps demonstrate how testing works for now-python: vercel/vercel@8253e76

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

This fixture: https://github.com/vercel/vercel/blob/fcb14fa70e800ff2bf387120ebdaf65affea6661/packages/now-python/test/fixtures/12-asgi-function/index.py is exercised by this test: https://github.com/vercel/vercel/blob/8a68211cad8d2afae02ac1b85184e07d8911d47b/packages/now-python/test/fixtures/12-asgi-function/now.json#L10

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

Also possibly relevant: vercel/vercel@8503af7#diff-9fd170c5d0171ce84976ebc317c15bcb is a commit titled "[now-python] Fix space encoding"

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

Just saw this one again in the wild - upgrading to latest Vercel builder in #34 may fix this.

from datasette-publish-vercel.

styfle avatar styfle commented on June 2, 2024

Yep, fixed in #35

from datasette-publish-vercel.

simonw avatar simonw commented on June 2, 2024

Yup, that fixes it: https://datasette-vercel-python-fix.vercel.app/fixtures?sql=select+date(%27now%27%2C+%22%2B30+days%22)

from datasette-publish-vercel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.