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
Return useful error message on potential HTTP connect to Transport port #10108
Return useful error message on potential HTTP connect to Transport port #10108
Conversation
bufferStartsWith(buffer, readerIndex, 'H', 'E', 'A', 'D', ' ') || | ||
bufferStartsWith(buffer, readerIndex, 'D', 'E', 'L', 'E', 'T', 'E', ' ') || | ||
bufferStartsWith(buffer, readerIndex, 'O', 'P', 'T', 'I', 'O', 'N', 'S', ' ') || | ||
bufferStartsWith(buffer, readerIndex, 'T', 'R', 'A', 'C', 'E', ' ')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing PATCH
here?
Left one comment, This looks pretty good to me, now I'm just curious how different clients will handle a non-HTTP response :) |
I tested with curl and chrome and those displayed correctly.. (display as in returned the string as response) |
22221f4
to
a1fdfe7
Compare
updated to support PATCH |
d8b5771
to
7d9e146
Compare
return true; | ||
} | ||
|
||
public class HttpOnTransportException extends ElasticsearchException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add javadocs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
Left comments about adding documentation, LGTM |
7d9e146
to
b460a02
Compare
if (ctx.getChannel().isOpen()) { | ||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(e.getCause().getMessage().getBytes(Charsets.UTF_8)); | ||
ctx.getChannel().write(buffer); | ||
ctx.getChannel().close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this close()
should be in a finally
block in case the write fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this to use the channel future as it was intended to be.. so when the future is done, close
is called
LGTM |
In case a HTTP client connects to the transport protocol and issues a HTTP method followed by a space, we can just try to be smart and return a string back to the client to point the user to the fact that the wrong port has been used. Closes elastic#2139 Closes elastic#10108
2b777f1
to
b833451
Compare
In case a HTTP client connects to the transport protocol and issues a
HTTP method followed by a space, we can just try to be smart and return
a string back to the client to point the user to the fact that the wrong
port has been used.
Closes #2139