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

Fixes CORS handling so that it uses the defaults #19522

Merged
merged 4 commits into from
Jul 22, 2016

Conversation

abeyad
Copy link

@abeyad abeyad commented Jul 20, 2016

Fixes CORS handling so that it uses the defaults for for http.cors.allow-methods
and http.cors.allow-headers if none are specified in the config.

Closes #19520

…methods

and http.cors.allow-headers if none are specified in the config.

Closes elastic#19520
@abeyad abeyad added >bug :Core/Infra/REST API REST infrastructure and utilities v5.0.0-alpha5 review labels Jul 20, 2016
}

public static String[] splitStringByCommaToArray(final String s) {
if (s == null || s.isEmpty()) return Strings.EMPTY_ARRAY;
else return s.split(",");
}

public static Set<String> splitStringToSet(final String s, final char c) {
public static Set<String> splitStringByCommaAndTrim(final String s) {
Copy link
Member

Choose a reason for hiding this comment

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

can you just call spliStringToSet with true? why do we need another variant when the method this calls is public

Copy link
Member

Choose a reason for hiding this comment

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

actually, i see 9 uses of the original method, and none look like they would want to retain whitespace. i think we should just change the behavior?

Copy link
Author

Choose a reason for hiding this comment

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

yeah i wasn't sure what was best, most uses are reading rest request params which shouldn't have the whitespace anyway. i'm up for changing it to always do trim (unless that's the delimiter char) and not have that option on the method. that would make my extra wrapper method even more unnecessary and could go away.

@abeyad
Copy link
Author

abeyad commented Jul 20, 2016

@rjernst i pushed ec66147

@abeyad abeyad mentioned this pull request Jul 21, 2016
@abeyad
Copy link
Author

abeyad commented Jul 21, 2016

@rjernst did the last commit address your concerns?

@rjernst
Copy link
Member

rjernst commented Jul 21, 2016

I don't think you need the doTrim local, but other than that yes, thank you.

the beginning and end of all split strings.
@abeyad
Copy link
Author

abeyad commented Jul 21, 2016

@rjernst I pushed 8aa5266

@@ -521,16 +534,29 @@ public static String cleanPath(String path) {
final int len = chars.length;
int start = 0; // starting index in chars of the current substring.
int pos = 0; // current index in chars.
int whitespaceStart = -1; // the position of the start of the current whitespace, -1 if not on whitespace
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this, I think you could do just like with start, and have an end var that marks the current end of the token, and do not increment it when you find whitespace?

Copy link
Member

Choose a reason for hiding this comment

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

This means the size of the token would always be end - start too.

Copy link
Author

Choose a reason for hiding this comment

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

I pushed 34c5b1e

@rjernst
Copy link
Member

rjernst commented Jul 22, 2016

LGTM, thanks!

@abeyad
Copy link
Author

abeyad commented Jul 22, 2016

@rjernst thanks for the review!

@abeyad abeyad merged commit 2b9cfff into elastic:master Jul 22, 2016
@abeyad abeyad deleted the fix/cors-allow-methods-default branch July 22, 2016 16:25
@jasontedor jasontedor mentioned this pull request Jul 23, 2016
5 tasks
@s1monw
Copy link
Contributor

s1monw commented Sep 9, 2016

@jasontedor @abeyad has this been ported to netty 4?

@jasontedor
Copy link
Member

has this been ported to netty 4?

@s1monw I think #19874 is the port?

@s1monw
Copy link
Contributor

s1monw commented Sep 9, 2016

thx @jasontedor I see you checked the box on the meta issue too ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/REST API REST infrastructure and utilities v5.0.0-alpha5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants