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

Add notFound function to set respondNotFound callback (#44) #54

Merged
merged 5 commits into from
Jun 23, 2016

Conversation

cchan
Copy link
Contributor

@cchan cchan commented Jun 20, 2016

This should fix #44. Perhaps we should add a test for this, too.

@manast
Copy link
Member

manast commented Jun 20, 2016

Thanks for the patch. It would be nice also to update the documentation so that this functionality becomes public.

@cchan
Copy link
Contributor Author

cchan commented Jun 20, 2016

Improved the NotFound function, and updated the readme! :) :)

@@ -295,14 +301,14 @@ __Arguments__
Gives Redbird a callback function with two parameters, the ExpressJS request
Copy link
Member

Choose a reason for hiding this comment

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

Its not a expressJs object but just the standard http request and response objects: https://nodejs.org/api/http.html#http_class_http_clientrequest https://nodejs.org/api/http.html#http_class_http_serverresponse

@@ -174,7 +174,7 @@ function ReverseProxy(opts){
if(target){
proxy.ws(req, socket, head, {target: target});
}else{
notFound(socket);
respondNotFound(req, socket);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't an HTTP response object, but does a socket have the same set of properties and methods as an HTTP response?

Copy link
Member

Choose a reason for hiding this comment

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

it has the write and the end, I am not sure of the status method, probably not. I think that this codepath never happens in practice though, thats why it has been working so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if it would be valid anyway to attempt to send a "not found" over a socket.
Actually, wouldn't the destination already have had to be found before the server can emit the "upgrade" event? So there would be no need for the custom error message because that should never happen in practice (unless you have the proxy settings changing in the middle of a connection or something weird like that)

Copy link
Member

Choose a reason for hiding this comment

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

thats what I meant in my previous comment :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:P
If we don't seem to really care about this use case, we can perhaps open a separate issue and merge this? I haven't actually tested whether sockets work at all, so I don't know haha

@manast manast merged commit 97f27c8 into OptimalBits:master Jun 23, 2016
@cchan cchan mentioned this pull request Jun 23, 2016
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.

Default route
2 participants