Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST listener improvements for liteserv #2117

Draft
wants to merge 48 commits into
base: master
Choose a base branch
from
Draft

Commits on Sep 6, 2024

  1. Fixed UB when a CollectionChangeObserver deletes itself in its callback

    The code that calls observers attempted to protect itself from the
    list being mutated while it was iterating, but apparently it didn't
    work well enough.
    I changed the code so it now iterates the list collecting the
    observer pointers, and then calls them afterwards.
    While I was debugging this I noticed SequenceTracker doesn't have a
    logging identifier, so I added it.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    e3f46ff View commit details
    Browse the repository at this point in the history
  2. StringUtil: Improved split

    - Fixed a bug where the existing `split` method would report an
      extra empty string, if the input string ends with the delimiter.
    - Added a variant of `split` that returns a vector instead of using
      a callback.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    124d6b9 View commit details
    Browse the repository at this point in the history
  3. TCPSocket: Fixed misleading error message

    If a response had neither a Content-Length, Transfer-Encoding nor
    Connection header, the error would be "Unsupported 'Connection'
    response header", which is misleading.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    fc77257 View commit details
    Browse the repository at this point in the history
  4. REST: Clean up JSON generation with new Encoder APIs

    Use Encoder::writeFormatted to simplify creating JSON.
    Also used the not-at-all-new `enc["key"] = value` form.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    aefd99b View commit details
    Browse the repository at this point in the history
  5. Listener: Fixed lock pessimization in Server

    Server was locking its mutex while calling a handler. This made it
    impossible to handle more than one HTTP request at once. Especially
    bad when handling `/db/_replicate`, whose handler blocks until the
    replication completes!
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    131b47b View commit details
    Browse the repository at this point in the history
  6. HTTP: Warn if JSON response is unparseable

    Body::bodyAsJSON() would silently return nullptr if the response is
    supposed to be JSON but fails to parse. This made some test failures
    hard to track down today! It now logs a warning.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    1b8a272 View commit details
    Browse the repository at this point in the history
  7. REST: Implemented _changes feed

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    4c3f82e View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e8bce93 View commit details
    Browse the repository at this point in the history
  9. REST listener improvements

    - Added "Server:" response header
    - Added "ETag:" response header to document response
    - Honor "If-None-Match" request header getting document
    - Added "total_rows" and "update_seq" to _all_docs response
    - Suppress response body on HEAD request
    - _changes feed improvements:
      - Flush output before waiting
      - No heartbeat if ?heartbeat=0
      - Longest possible timeout if ?timeout=0
      - Stop on socket error
      - Make logging verbose not info
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    dd2edf5 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8b99ef5 View commit details
    Browse the repository at this point in the history
  11. Improvements for liteserv

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    03280ac View commit details
    Browse the repository at this point in the history
  12. Improved how RequestResponse sends headers

    Instead of writing them immediately, save them in a Headers object.
    That gives client code more flexibility about when it can set
    headers -- it doesn't have to wait until after the status line is
    sent.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    53cce56 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    71b403e View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    e834e99 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    812c3bc View commit details
    Browse the repository at this point in the history
  16. query parameterNames

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    b53e3b4 View commit details
    Browse the repository at this point in the history
  17. clang-format

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    6ec8b81 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    473d861 View commit details
    Browse the repository at this point in the history
  19. StringUtils: Added split2()

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    6ca1274 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    d4787ce View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    8244f85 View commit details
    Browse the repository at this point in the history
  22. REST: Write a newline at the end of a continuous-changes line

    It doesn't make a difference functionally, but it works around curl
    not displaying the last line of output.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    2321296 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    167f925 View commit details
    Browse the repository at this point in the history
  24. Fixed NotFound error creating BlobStore

    Discovered this scenario while testing replications in liteserv:
    1. Create an empty database
    2. Close it
    3. Reopen it without giving the kC4DB_Create flag
    4. Access the BlobStore, i.e. call c4Database::getBlobStore()
    
    Result: getBlobStore fails with a NotFound error.
    The reason is that step 1 didn't instantiate the BlobStore or create
    the Attachments directory; and then in step 4 the db's flags don't
    include kC4DB_Create so the BlobStore instance won't create the
    directory.
    
    Fixed by passing the kC4DB_Create flag to the C4BlobStore constructor
    whenever the database is writeable.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    6609baa View commit details
    Browse the repository at this point in the history
  25. clang-format

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    1b4e795 View commit details
    Browse the repository at this point in the history
  26. REST: Refactoring RESTListener+Replicate

    - Moved all the request parsing out of the Task class.
    - One-shot replication does not block response until finished.
    - Returns 202 Accepted status, not 200.
    - To cancel a replication you now set the `cancel` property to the
      `session_id` of the task.
    - Preliminary support for channel/docID filters, but they're not
      per-collection yet.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    055d3a5 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    3568da9 View commit details
    Browse the repository at this point in the history
  28. REST: Rudimentary API version checking

    Client specifies the version in a header, e.g:
      API-Version: 1
      API-Version: 3.5
    If missing, it defaults to 1.0.
    Handlers support a specific major version, and an incompatible
    version in a request triggers a 400 response.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    7a0cfdf View commit details
    Browse the repository at this point in the history
  29. READ: Added API to tell C4Listener to start a replication

    CBL will probably never use this, but liteserv needs it.
    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    417effd View commit details
    Browse the repository at this point in the history
  30. GCC fix

    snej committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    d768e61 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    da7e213 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    b48da47 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    6322ff0 View commit details
    Browse the repository at this point in the history

Commits on Sep 10, 2024

  1. Configuration menu
    Copy the full SHA
    b3adc5c View commit details
    Browse the repository at this point in the history
  2. Cleaned up some logging

    snej committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    a0d5abb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8e2d598 View commit details
    Browse the repository at this point in the history
  4. REST: Don't use regexes to look up handlers

    They're slow, and we only need very simple pattern matching.
    snej committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    7173c9a View commit details
    Browse the repository at this point in the history
  5. clang-format

    snej committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    e920a91 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    2d409a4 View commit details
    Browse the repository at this point in the history
  7. REST: Don't get peer address str on every request

    Rather, get it when accepting the socket connection and reuse it.
    Yes, this was actually a significant time-sink, roughly 6% of the
    time to handle a simple request.
    snej committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    b6cd702 View commit details
    Browse the repository at this point in the history
  8. minor cleanup of Request

    snej committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    dad80fa View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8d603db View commit details
    Browse the repository at this point in the history
  10. REST: Fixed DELETE /db handler

    There were issues making it work with the DatabasePool.
    snej committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    1ba7b03 View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2024

  1. REST: Make server name/version configurable [API change]

    Added `serverName`, `serverVersion` to C4ListenerConfig.
    By default these should be nullslice.
    snej committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    d44bba8 View commit details
    Browse the repository at this point in the history
  2. Updated Fleece for Backtrace fix

    snej committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    db2263b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    63e41ae View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0b9438d View commit details
    Browse the repository at this point in the history
  5. clang-format

    snej committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    7fc76e8 View commit details
    Browse the repository at this point in the history