rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
260 stars 11 forks source link

Mist not parsing query string correctly #7

Closed mikeyjones closed 2 years ago

mikeyjones commented 2 years ago

Hi Rawhat,

We have an issue with how Mist is parsing query strings. You can see this with the sample below:

import gleam/io
import mist
import gleam/http/response
import gleam/bit_builder
import gleam/erlang

pub fn main() {
  assert Ok(_) =
    mist.run_service(
      8080,
      fn(req) {
        io.debug(req.path)
        io.debug(req.query)

        response.new(200)
        |> response.set_body(bit_builder.from_bit_string(<<
          "hello, world!":utf8,
        >>))
      },
    )
  erlang.sleep_forever()
}

Calling the server with http://localhost:8080/?test=text

It will print in the command line:

"/?test=text" // <- path
None // <- query

The Request should have the following: path = "/" query = Some("test=text")

rawhat commented 2 years ago

https://github.com/rawhat/mist/commit/9d0971e7c191b9a2f29e50c3d229e16df89ef6b1

I think this should cover it! Thanks for catching this. Let me know if you still have issues with this, or any others 🙂