GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Populate headers for HTTP OPTIONS requests by DavidPetkovsek · Pull Request #1062 · CrowCpp/Crow

Conversation

@DavidPetkovsek

@DavidPetkovsek DavidPetkovsek commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

When running middleware for an HTTP OPTIONS request (for CORS for example). There is a bug where the headers from the request are not populated. Also referenced here: #721 (comment).

The reason this occurs is because the parser will parse the URL first (before the headers) and in the handle_url function, it will end parsing the request early, returning the response, and triggering the middleware.

The proposed changes will prevent us from exiting early in the handle_url function and instead exit early at the handle_headers function, which is executed when all of the headers have finished parsing.

It is also important to note that OPTIONS requests are fully handled within crow, and crow will never call a user defined OPTIONS route.

I believe this Fixes #721.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gittiver

gittiver commented Jul 23, 2025

Copy link
Copy Markdown
Member

The automatic test seems to hang somewhere, all automatic builds are stopped there without finishing the test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DavidPetkovsek

DavidPetkovsek commented Jul 27, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

The automatic test seems to hang somewhere, all automatic builds are stopped there without finishing the test.

It is hanging on

Crow/tests/unittest.cpp

Line 2047 in 584560f

resp = HttpClient::request(LOCALHOST_ADDRESS, port,

Which is testing an invalid HTTP packet. Causing the parser to report an error to do_read() here

Crow/include/crow/http_connection.h

Line 492 in 584560f

CROW_LOG_DEBUG << self << " from read(1) with description: \"" << http_errno_description(static_cast<http_errno>(self->parser_.http_errno)) << '\"';

Which hangs.

The unit test never hang before because the OPTIONS packet would stop parsing early at the url stage.


From reading the unit tests file I believe this unit test was not designed to test an invalid packet. Correcting the packet causes that specific unit test to no longer hang.

That being said, now one of the tests fail, so I will work on that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DavidPetkovsek

DavidPetkovsek commented Jul 27, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Turns out it was the same thing as the previous comment. The unit test in question was failing because the result it was getting was empty. It was empty because an error was thrown ( stream ended at an unexpected time ) due to an malformed packet. Correcting the packet causes the unit test to no longer error and now pass.

The unit test never failed before because the OPTIONS packet would stop parsing early at the url stage.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DavidPetkovsek

DavidPetkovsek commented Jul 27, 2025

Copy link
Copy Markdown
Contributor Author

@gittiver I believe this is ready for your review once again. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DavidPetkovsek
DavidPetkovsek force-pushed the master branch from 22fba82 to a6c7aff Compare March 3, 2026 15:37
@DavidPetkovsek
DavidPetkovsek force-pushed the master branch from 92b4a6a to a6c5e00 Compare March 21, 2026 14:37
DavidPetkovsek and others added 6 commits March 21, 2026 10:58
@DavidPetkovsek
Handle headers for HTTPMethod::Options
2816221
@DavidPetkovsek
Prevent memory leak from Options requests trying to upgrade into webs…
a32a84f
…ockets for websocket endpoints
@DavidPetkovsek
Fix erroneous unit test
1c37d57
@DavidPetkovsek
Fix erroneous unit test 2
6d83f6d
@DavidPetkovsek
Exit early for requests with no route for optional too
ee421d6
@DavidPetkovsek
fix handle_header
ff68f50
@DavidPetkovsek
DavidPetkovsek force-pushed the master branch from a6c5e00 to ff68f50 Compare March 21, 2026 14:58
@DavidPetkovsek

DavidPetkovsek commented Mar 21, 2026

Copy link
Copy Markdown
Contributor Author

^ rebased onto master

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gittiver
gittiver approved these changes Mar 23, 2026
View reviewed changes
Comment thread .github/workflows/build_and_test.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .github/workflows/doxygen-gh-pages.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gittiver
gittiver merged commit 7e3ed0b into CrowCpp:master Mar 23, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@BrewTestBot BrewTestBot mentioned this pull request Mar 29, 2026
crow 1.3.2 Homebrew/homebrew-core#274906
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gittiver gittiver gittiver approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Crow does not reply to browser preflight messages correctly when using CORs middleware

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@DavidPetkovsek @gittiver
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.