Git Product home page Git Product logo

Comments (7)

Asmod4n avatar Asmod4n commented on September 22, 2024 1

@anatol found another uri parser which is like phr, it is based on the NGINX and Node parser. https://github.com/Zewo/uri_parser

from picohttpparser.

anatol avatar anatol commented on September 22, 2024

Let me know what do you think about this idea.

If you think url parser should be different project independent of H2O then I might start looking at implementing it. Most likely with Ragel state machine compiler and picohttpparser-like API.

from picohttpparser.

kazuho avatar kazuho commented on September 22, 2024

Interesting.

However I wonder if it would be a easy task to reach consensus upon how a query parsing API should be designed. Won't people want to use different structures for storing the key-value pairs of a query?

The concern makes me think that the best way for you to go forward is to create a separate repository for implementing a query parser that most fits your need, and then show it to others.

How does it sound?

from picohttpparser.

anatol avatar anatol commented on September 22, 2024

Won't people want to use different structures for storing the key-value pairs of a query?

This is going to be the the same key-value structure as used for headers in http parser. The name could be either keyvalue of queryparams (I like the keyvalue).

from picohttpparser.

kazuho avatar kazuho commented on September 22, 2024

This is going to be the the same key-value structure as used for headers in http parser. The name could be either keyvalue of queryparams (I like the keyvalue).

Well, that is the point I cannot agree / is the reason why I suggested you should better create a separate library for parsing queries.

I am not sure if it is practical to expect that the upper bound of the number of key-values pairs in a query is relatively small (as is the case for the HTTP headers). IMO it is hard to expect the upper bound in case of queries, and therefore the query parser should either dynamically allocate memory or call a callback to allocate memory. It might also be necessary to use a non-O(n) structure for searching a key within the pairs (i.e. use hashtable for storing key-value pairs).

from picohttpparser.

anatol avatar anatol commented on September 22, 2024

I am not sure if it is practical to expect that the upper bound of the number of key-values pairs in a query is relatively small

Well, in practice URI length is limited. Most browsers think that URI should not be longer than 2048 symbols and it is good enough hard upper bound for query params. i.e. we can expect that there will no be more than 1000 params in the URI.

But my idea that I had in mind is parser returns an error if number of params is larger than provided structure (like in your http parser). In this case user can reparse the URI with bigger array.

Okay, here is real quick implementation for this idea https://github.com/anatol/uriparser

from picohttpparser.

kazuho avatar kazuho commented on September 22, 2024

Thank you for elaborating.

I still believe that it should be implemented as a separate library (or in other words there is no necessity that URL parsing should be implemented within picohttpparser).

from picohttpparser.

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.