Code Monkey home page Code Monkey logo

Comments (6)

vinniefalco avatar vinniefalco commented on May 7, 2024

This brings up an interesting question, what should the behavior of basic_headers::replace do? There are a few choices:

  1. Replace the first occurrence
  2. Replace the first occurrence, remove any additional occurrences
  3. Replace the first occurrence if there is only one occurrence, else throw an exception.

from beast.

vinniefalco avatar vinniefalco commented on May 7, 2024

Another problem, what happens with basic_headers::operator[] if there is more than one field with the same name? I guess it could return the first occurrence.

from beast.

0x0ACB avatar 0x0ACB commented on May 7, 2024

i would remove operator[] and instead do something like equal_range in multimap or maybe return a vector with all values.

i would say replace should do remove(name) insert(name, value)

from beast.

vinniefalco avatar vinniefalco commented on May 7, 2024

The problem with removing operator[] is that it inconveniences the majority of use-cases where only one field with a given name exists. For example:
https://github.com/vinniefalco/Beast/blob/master/include/beast/websocket/impl/stream.ipp#L970

Also note that the fields in the headers are in insertion order and not in set order. This is an important detail, because proxies are not supposed to reorder header fields. Many other HTTP libraries make the mistake of returning the fields in alphabetical order, which breaks proxies.

from beast.

vinniefalco avatar vinniefalco commented on May 7, 2024

This seems to pass tests, it changes basic_headers to behave like a std::multiset
https://github.com/vinniefalco/Beast/commits/rfc

from beast.

vinniefalco avatar vinniefalco commented on May 7, 2024

Fixed in 1.0.0-b8

from beast.

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.