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

Possibility to disable JSONP. #314

Merged
merged 4 commits into from Jun 23, 2014
Merged

Conversation

rase-
Copy link
Contributor

@rase- rase- commented Jun 22, 2014

A first pass at being able to disable JSONP polling. Totally up for discussion.

Enables disabling by an option noJSONP that can be set to true (false by default). If set to true and trying to open a polling connection, we move immediately to a possible next transport. If there is not transport left to open with, we emit an error that no transports are available.

We could make our polling transports also not autodetectable as xhr and json so that we could specify transport literals like: ['xhr', 'websocket'] to specify we don't want JSONP polling as an option. This would, however, complicate the handling of transports and upgrades and I'm not sure if it's worth it for this one edge case.

Thoughts on this @guille?

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

Thoughts on jsonp: false? Considering we also have multiple: false for example.

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

cc @kevin-roark @defunctzombie

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

Great work btw, especially on test support.

@kevin-roark
Copy link

what about one jsonp option to handle forceJSONP and noJSONP. a la jsonp: 'force' or jsonp: false (with the default assumed to be jsonp: true. If that is confusing then i'm down with jsonp: false.

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

That would have been good had we not already had forceJSONP I think

@kevin-roark
Copy link

oh yeah backwards compatibility and whatnot. jsonp: false probably best then

@defunctzombie
Copy link
Contributor

LGTM. I would have favored having two transports (since they really are two different ways of transporting the data backed by a common mechanism of xhr) but this is certainly the smaller code change.

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

I agree with you @defunctzombie. Having just polling with "transport polymorphism" is more of a (bad) impl detail, and we should have 2 transports. We should add the option now, and refactor it in that way too.

@rase-
Copy link
Contributor Author

rase- commented Jun 23, 2014

@guille so we should for now have an option like this one, and later refactor the transports so you don't necessarily ned polymorphism? Or should we go for the separation of polling already now?

jsonp: false would be much much better. I'll make the change.

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

Right. Moving forward we'd have polling-xhr and polling-jsonp independent transports.

@3rd-Eden
Copy link
Contributor

Why would you add this? It doesn't solve anything, it doesn't provide any additional stability and allowsing people to connect with websockets first instead JSONP makes no sense for project which advertises that it's using known working transports before trying to upgrade to websockets..

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

I'm discussing the ability to disable JSONP in a cleaner way.

@3rd-Eden
Copy link
Contributor

@guille But why would you want to disable JSONP in the first place?

@rauchg
Copy link
Contributor

rauchg commented Jun 23, 2014

I don't, but many people have asked for it.

@rase-
Copy link
Contributor Author

rase- commented Jun 23, 2014

Renamed option and changed the constructor check to try-catch and error throw.

@defunctzombie
Copy link
Contributor

Some people think it is insecure.
On Jun 23, 2014 7:20 AM, "Arnout Kazemier" notifications@github.com wrote:

@guille https://github.com/guille But why would you want to disable
JSONP in the first place?


Reply to this email directly or view it on GitHub
#314 (comment)
.

var transport = this.createTransport(transport);

// Retry with the next transport if the transport is disabled (jsonp: false)
var transort;
Copy link
Contributor

Choose a reason for hiding this comment

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

transort

@@ -71,6 +71,7 @@ function Socket(uri, opts){
this.upgrade = false !== opts.upgrade;
this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
this.forceJSONP = !!opts.forceJSONP;
this.jsonp = null == opts.jsonp ? true : !!opts.jsonp;
Copy link
Contributor

Choose a reason for hiding this comment

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

false !== this.jsonp ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better. Will change.

rauchg added a commit that referenced this pull request Jun 23, 2014
@rauchg rauchg merged commit 0d0e943 into socketio:master Jun 23, 2014
@rase- rase- deleted the add/jsonp-disabling branch June 23, 2014 17:13
@mokesmokes
Copy link
Contributor

@rase- pls update the readme

@rase-
Copy link
Contributor Author

rase- commented Jun 23, 2014

Ah, will do. Thanks @mokesmokes.

@rase-
Copy link
Contributor Author

rase- commented Jun 23, 2014

#315

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.

None yet

6 participants