spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

Explain usage in browsers #169

Closed simevidas closed 10 years ago

simevidas commented 10 years ago

(Sorry for the n00b question.) I'm not sure that the "Client" code means (in the README). It starts with:

var spdy = require('spdy');
var http = require('http');

Does this mean that I have to load these packages onto the web page in the browser? Like with browserify? Is there a ready-to-use browser script that I could directly load via <script> so that I don't have to build it via browserify?

indutny commented 10 years ago

Sorry, I don't think that it would work with browsers.

simevidas commented 10 years ago

Ah, so the "Client" code isn't meant for browsers. I see.

netpoetica commented 10 years ago

This image from the Chromium whitepaper helps a little bit to explain what is meant by "client":

screen shot 2014-07-15 at 5 36 38 pm

"SPDY adds a session layer atop of SSL that allows for multiple concurrent, interleaved streams over a single TCP connection. The usual HTTP GET and POST message formats remain the same; however, SPDY specifies a new framing format for encoding and transmitting the data over the wire."

So in this instance "client" is really just the SPDY client that sits over your HTTP server

simevidas commented 10 years ago

@netpoetica In the case of the the code examples in the README, "Client" means a Node module, I think.

netpoetica commented 10 years ago

@simevidas Yes, that is correct, I think we are saying the same thing :-) "client" is a program (process) written in node (in this case).

I think it's helpful to consult to spec on this one as well -it probably sounds a little loopy, but it's because they are trying to be clear about the fact that your SPDY client is responsible for initiating a SPDY session, not your server. (Note: I reorganized the definitions a little bit to help illustrate the point more clearly)

1.2.  Definitions
      endpoint: Either the client or server of a connection.
      client: The endpoint initiating the SPDY session.
      server: The endpoint which did not initiate the SPDY session.
      connection: A transport-level connection between two endpoints.

...
2.1.  Session (Connections)
   The SPDY framing layer (or "session") runs atop a reliable transport
   layer such as TCP [RFC0793].  The client is the TCP connection
   initiator.  SPDY connections are persistent connections.

Section 3 describes the direction of requests and responses between the server and SPDY client in a way that might help clarify it as well.

Hosar commented 7 years ago

@simevidas how do you handle the browser request? with a library like superagent?