Skip to content

Update HTTPServer.cpp to allow CORS - #1571

Closed
GertOdB wants to merge 3 commits into
OpenLightingProject:masterfrom
GertOdB:patch-1
Closed

GertOdB wants to merge 3 commits into
OpenLightingProject:masterfrom
GertOdB:patch-1

Conversation

@GertOdB

@GertOdB GertOdB commented Jul 21, 2019

Copy link
Copy Markdown

This enables Cross-Origin Resource Sharing (CORS) as requested in here : #1547

This changes enable Cross-Origin Resource Sharing (CORS) as requested in here : OpenLightingProject#1547

@peternewman peternewman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GertOdB,

You can switch to the existing constant MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN so you don't need to write it out by hand:
https://git.gnunet.org/libmicrohttpd.git/tree/src/include/microhttpd.h#n846

@peternewman peternewman added this to the 0.11.0 milestone Aug 24, 2019

@peternewman peternewman left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just in terms of covering all the bases, this header was added in https://git.gnunet.org/libmicrohttpd.git/commit/src/include/microhttpd.h?id=fe4fa4d3c2f47197da462fedbbd3aa364fab2279 which was on 2013-09-18 . That's probably long enough ago we can just get away with it, if someone sticks an issue in, we can add some cotton wool to fall back.

It would probably be nice to add a wrapper function like set no cache:

/**
* @brief Set the appropriate headers so this response isn't cached
*/
void HTTPResponse::SetNoCache() {
SetHeader(MHD_HTTP_HEADER_CACHE_CONTROL, "no-cache, must-revalidate");
}

It's fine to merge as is, but this would make it just a bit better if you're happy to do the changes @GertOdB ?

@peternewman

Copy link
Copy Markdown
Member

Closing this in favour of #1625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants