Giter Club home page Giter Club logo

spdylay's Introduction

Spdylay - SPDY C Library

This is an experimental implementation of Google's SPDY protocol in C.

This library provides SPDY version 2, 3 and 3.1 framing layer implementation. It does not perform any I/O operations. When the library needs them, it calls the callback functions provided by the application. It also does not include any event polling mechanism, so the application can freely choose the way of handling events. This library code does not depend on any particular SSL library (except for example programs which depend on OpenSSL 1.0.1 or later).

This project also develops SPDY client, server and proxy on top of Spdylay library. See SPDY Client and Server Programs section.

Development Status

Most of the SPDY/2, SPDY/3 and SPDY/3.1 functionality has been implemented. In both versions, the direct support of server-push has not been available yet. The application can achieve server-push using primitive APIs though.

As described below, we can create SPDY client and server with the current Spdylay API.

Requirements

The following packages are needed to build the library:

  • pkg-config >= 0.20
  • zlib >= 1.2.3

To build and run the unit test programs, the following packages are needed:

  • cunit >= 2.1

To build and run the example programs, the following packages are needed:

  • OpenSSL >= 1.0.1

To enable -a option (getting linked assets from the downloaded resource) in spdycat (one of the example program), the following packages are needed:

  • libxml2 >= 2.7.7

To build SPDY/HTTPS to HTTP reverse proxy shrpx (one of the example program), the following packages are needed:

  • libevent-openssl >= 2.0.8

If you are using Ubuntu 12.04, you need the following packages installed:

$ apt-get install autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libevent-dev

Build from git

Building from git is easy, but please be sure that at least autoconf 2.68 is used:

$ autoreconf -i
$ automake
$ autoconf
$ ./configure
$ make

Building documentation

To build documentation, run:

$ make html

The documents will be generated under doc/manual/html/.

The generated documents will not be installed with make install.

Building Android binary

In this section, we briefly describe how to build Android binary using Android NDK cross-compiler on Debian Linux.

We offer android-config and android-make scripts to make the build easier. To make these script work, NDK toolchain must be installed in the following way. First, let introduce ANDROID_HOME environment variable. We need to install toolchain under $ANDROID_HOME/toolchain. An user can freely choose the path for ANDROID_HOME. For example, to install toolchain under $ANDROID_HOME/toolchain, do this in the the directory where NDK is unpacked:

$ build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=$ANDROID_HOME/toolchain

The platform level is not important here because we don't use Android specific C/C++ API.

The dependent libraries, such as OpenSSL and libevent should be built with the toolchain and installed under $ANDROID_HOME/usr/local. We recommend to build these libraries as static library to make the deployment easier. libxml2 support is currently disabled.

We use zlib which comes with Android NDK, so we don't have to build it by ourselves.

Before running android-config and android-make, ANDOIRD_HOME environment variable must be set to point to the correct path.

After android-config, run android-make to compile sources. android-make is just include path to cross compiler in PATH and run make. So if you include path to corss compiler by yourself, you can just run make to build spdylay and tools as usual.

API

The public API reference is available on online. Visit http://tatsuhiro-t.github.io/spdylay/. All public APIs are in spdylay/spdylay.h. All public API functions as well as the callback function typedefs are documented.

SPDY Client and Server Programs

The src directory contains SPDY client and server implementations using Spdylay library. These programs are intended to make sure that Spdylay API is acutally usable for real implementation and also for debugging purposes. Please note that OpenSSL with NPN support is required in order to build and run these programs. At the time of this writing, the OpenSSL 1.0.1 supports NPN.

Spdycat - SPDY client

The SPDY client is called spdycat. It is a dead simple downloader like wget/curl. It connects to SPDY server and gets resources given in the command-line:

$ src/spdycat -h
Usage: spdycat [-Oansv23] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]
               [--key=<KEY>] [--no-tls] [-d <FILE>] [-m <N>] [-p <PROXY_HOST>]
               [-P <PROXY_PORT>] <URI>...

OPTIONS:
    -v, --verbose      Print debug information such as reception/
                       transmission of frames and name/value pairs.
    -n, --null-out     Discard downloaded data.
    -O, --remote-name  Save download data in the current directory.
                       The filename is dereived from URI. If URI
                       ends with '/', 'index.html' is used as a
                       filename. Not implemented yet.
    -2, --spdy2        Only use SPDY/2.
    -3, --spdy3        Only use SPDY/3.
    --spdy3-1          Only use SPDY/3.1.
    -t, --timeout=<N>  Timeout each request after <N> seconds.
    -w, --window-bits=<N>
                       Sets the initial window size to 2**<N>.
    -a, --get-assets   Download assets such as stylesheets, images
                       and script files linked from the downloaded
                       resource. Only links whose origins are the
                       same with the linking resource will be
                       downloaded.
    -s, --stat         Print statistics.
    -H, --header       Add a header to the requests.
    --cert=<CERT>      Use the specified client certificate file.
                       The file must be in PEM format.
    --key=<KEY>        Use the client private key file. The file
                       must be in PEM format.
    --no-tls           Disable SSL/TLS. Use -2, -3 or --spdy3-1 to
                       specify SPDY protocol version to use.
    -d, --data=<FILE>  Post FILE to server. If - is given, data
                       will be read from stdin.
    -m, --multiply=<N> Request each URI <N> times. By default, same
                       URI is not requested twice. This option
                       disables it too.
    -p, --proxy=<HOST> Use this host as a SPDY proxy
    -P, --proxy-port=<PORT>
                       Use this as the port of the SPDY proxy if
                       one is set
    --color            Force colored log output.

$ src/spdycat -nv https://www.google.com/
[  0.021] NPN select next protocol: the remote server offers:
          * spdy/4a4
          * spdy/3.1
          * spdy/3
          * http/1.1
          NPN selected the protocol: spdy/3.1
[  0.029] Handshake complete
[  0.029] recv SETTINGS frame <version=3, flags=0, length=20>
          (niv=2)
          [4(1):100]
          [7(0):1048576]
[  0.029] recv WINDOW_UPDATE frame <version=3, flags=0, length=8>
          (stream_id=0, delta_window_size=983040)
[  0.029] send SYN_STREAM frame <version=3, flags=1, length=221>
          (stream_id=1, assoc_stream_id=0, pri=3)
          :host: www.google.com
          :method: GET
          :path: /
          :scheme: https
          :version: HTTP/1.1
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: spdylay/1.2.0-DEV
[  0.080] recv SYN_REPLY frame <version=3, flags=0, length=619>
          (stream_id=1)
          :status: 302 Found
          :version: HTTP/1.1
          alternate-protocol: 443:quic
          cache-control: private
          content-length: 262
          content-type: text/html; charset=UTF-8
          date: Tue, 19 Nov 2013 13:47:18 GMT
          location: https://www.google.co.jp/
          server: gws
          x-frame-options: SAMEORIGIN
          x-xss-protection: 1; mode=block
[  0.080] recv DATA frame (stream_id=1, flags=1, length=262)
[  0.080] send GOAWAY frame <version=3, flags=0, length=8>
          (last_good_stream_id=0)

Spdyd - SPDY server

SPDY server is called spdyd and serves static files. It is single threaded and multiplexes connections using non-blocking socket. The static files are read using blocking I/O system call, read(2). It speaks SPDY/2 and SPDY/3:

$ src/spdyd --htdocs=/your/htdocs/ -v 3000 server.key server.crt
IPv4: listen on port 3000
IPv6: listen on port 3000
The negotiated next protocol: spdy/3.1
[id=1] [  1.296] send SETTINGS frame <version=3, flags=0, length=12>
          (niv=1)
          [4(0):100]
[id=1] [  1.297] recv SYN_STREAM frame <version=3, flags=1, length=228>
          (stream_id=1, assoc_stream_id=0, pri=3)
          :host: localhost:3000
          :method: GET
          :path: /README
          :scheme: https
          :version: HTTP/1.1
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: spdylay/1.2.0-DEV
[id=1] [  1.297] send SYN_REPLY frame <version=3, flags=0, length=116>
          (stream_id=1)
          :status: 200 OK
          :version: HTTP/1.1
          cache-control: max-age=3600
          content-length: 66
          date: Tue, 19 Nov 2013 14:35:24 GMT
          last-modified: Tue, 17 Jan 2012 15:39:01 GMT
          server: spdyd spdylay/1.2.0-DEV
[id=1] [  1.297] send DATA frame (stream_id=1, flags=0, length=66)
[id=1] [  1.297] send DATA frame (stream_id=1, flags=1, length=0)
[id=1] [  1.297] stream_id=1 closed
[id=1] [  1.297] recv GOAWAY frame <version=3, flags=0, length=8>
          (last_good_stream_id=0)
[id=1] [  1.297] closed

Currently, spdyd needs epoll or kqueue.

Shrpx - A reverse proxy for SPDY/HTTPS

For shrpx users who uses shrpx as SPDY proxy: Please consider migrating to nghttpx developed at nghttp2 project. nghttpx supports SPDY proxy too.

The shrpx is a multi-threaded reverse proxy for SPDY/HTTPS. It converts SPDY/HTTPS traffic to plain HTTP. It is initially developed as a reverse proxy, but now it has other operation modes such as a frontend forward proxy. For example, with --spdy-proxy (-s in shorthand) option, it can be used as secure SPDY proxy with a proxy (e.g., Squid) in the backend. With --cliet-proxy (-p) option, it acts like an ordinaly forward proxy but expects secure SPDY proxy in the backend. Thus it becomes an adapter to secure SPDY proxy for clients which does not support secure SPDY proxy. The another notable operation mode is --spdy-relay, which just relays SPDY/HTTPS traffic to the backend in SPDY. The following table summarizes the operation modes.

Mode option Frontend Backend Note
default SPDY/HTTPS HTTP Reverse proxy

--spdy --spdy-relay --client

SPDY/HTTPS SPDY/HTTPS HTTP

HTTP SPDY SPDY

SPDY proxy

--client-proxy HTTP SPDY Forward proxy

The shrpx supports configuration file. See --conf option and sample configuration file shrpx.conf.sample.

We briefly describe the architecture of shrpx here. It has a dedicated thread which listens on server sockets. When it accepted the incoming connection, it passes the file descriptor of the incoming connection to one of the worker thread. Each worker thread has its own event loop and can handle many connections using non-blocking I/O. The number of worker thread can be specified using the command-line option. The libevent is used to handle low-level network I/O.

Here is the command-line options:

$ src/shrpx -h
Usage: shrpx [-Dh] [-s|--client|-p] [-b <HOST,PORT>]
             [-f <HOST,PORT>] [-n <CORES>] [-c <NUM>] [-L <LEVEL>]
             [OPTIONS...] [<PRIVATE_KEY> <CERT>]

A reverse proxy for SPDY/HTTPS.

Positional arguments:
    <PRIVATE_KEY>      Set path to server's private key. Required
                       unless either -p or --client is specified.
    <CERT>             Set path to server's certificate. Required
                       unless either -p or --client is specified.

OPTIONS:

  Connections:
    -b, --backend=<HOST,PORT>
                       Set backend host and port.
                       Default: '127.0.0.1,80'
    -f, --frontend=<HOST,PORT>
                       Set frontend host and port.
                       Default: '0.0.0.0,3000'
    --backlog=<NUM>    Set listen backlog size.
                       Default: 256
    --backend-ipv4     Resolve backend hostname to IPv4 address
                       only.
    --backend-ipv6     Resolve backend hostname to IPv6 address
                       only.

  Performance:
    -n, --workers=<CORES>
                       Set the number of worker threads.
                       Default: 1
    --read-rate=<RATE> Set maximum average read rate on frontend
                       connection. Setting 0 to this option means
                       read rate is unlimited.
                       Default: 1048576
    --read-burst=<SIZE>
                       Set maximum read burst size on frontend
                       connection. Setting 0 to this option means
                       read burst size is unlimited.
                       Default: 4194304
    --write-rate=<RATE>
                       Set maximum average write rate on frontend
                       connection. Setting 0 to this option means
                       write rate is unlimited.
                       Default: 0
    --write-burst=<SIZE>
                       Set maximum write burst size on frontend
                       connection. Setting 0 to this option means
                       write burst size is unlimited.
                       Default: 0

  Timeout:
    --frontend-spdy-read-timeout=<SEC>
                       Specify read timeout for SPDY frontend
                       connection. Default: 180
    --frontend-read-timeout=<SEC>
                       Specify read timeout for non-SPDY frontend
                       connection. Default: 180
    --frontend-write-timeout=<SEC>
                       Specify write timeout for both SPDY and
                       non-SPDY frontends.
                       connection. Default: 60
    --backend-read-timeout=<SEC>
                       Specify read timeout for backend connection.
                       Default: 900
    --backend-write-timeout=<SEC>
                       Specify write timeout for backend
                       connection. Default: 60
    --backend-keep-alive-timeout=<SEC>
                       Specify keep-alive timeout for backend
                       connection. Default: 60
    --backend-http-proxy-uri=<URI>
                       Specify proxy URI in the form
                       http://[<USER>:<PASS>@]<PROXY>:<PORT>. If
                       a proxy requires authentication, specify
                       <USER> and <PASS>. Note that they must be
                       properly percent-encoded. This proxy is used
                       when the backend connection is SPDY. First,
                       make a CONNECT request to the proxy and
                       it connects to the backend on behalf of
                       shrpx. This forms tunnel. After that, shrpx
                       performs SSL/TLS handshake with the
                       downstream through the tunnel. The timeouts
                       when connecting and making CONNECT request
                       can be specified by --backend-read-timeout
                       and --backend-write-timeout options.

  SSL/TLS:
    --ciphers=<SUITE>  Set allowed cipher list. The format of the
                       string is described in OpenSSL ciphers(1).
                       If this option is used, --honor-cipher-order
                       is implicitly enabled.
    --honor-cipher-order
                       Honor server cipher order, giving the
                       ability to mitigate BEAST attacks.
    -k, --insecure     When used with -p or --client, don't verify
                       backend server's certificate.
    --cacert=<PATH>    When used with -p or --client, set path to
                       trusted CA certificate file.
                       The file must be in PEM format. It can
                       contain multiple certificates. If the
                       linked OpenSSL is configured to load system
                       wide certificates, they are loaded
                       at startup regardless of this option.
    --private-key-passwd-file=<FILEPATH>
                       Path to file that contains password for the
                       server's private key. If none is given and
                       the private key is password protected it'll
                       be requested interactively.
    --subcert=<KEYPATH>:<CERTPATH>
                       Specify additional certificate and private
                       key file. Shrpx will choose certificates
                       based on the hostname indicated by client
                       using TLS SNI extension. This option can be
                       used multiple times.
    --backend-tls-sni-field=<HOST>
                       Explicitly set the content of the TLS SNI
                       extension.  This will default to the backend
                       HOST name.
    --dh-param-file=<PATH>
                       Path to file that contains DH parameters in
                       PEM format. Without this option, DHE cipher
                       suites are not available.
    --verify-client    Require and verify client certificate.
    --verify-client-cacert=<PATH>
                       Path to file that contains CA certificates
                       to verify client certificate.
                       The file must be in PEM format. It can
                       contain multiple certificates.
    --client-private-key-file=<PATH>
                       Path to file that contains client private
                       key used in backend client authentication.
    --client-cert-file=<PATH>
                       Path to file that contains client
                       certificate used in backend client
                       authentication.
    --tls-proto-list=<LIST>
                       Comma delimited list of SSL/TLS protocol to
                       be enabled.
                       The following protocols are available:
                       TLSv1.2, TLSv1.1, TLSv1.0, SSLv3
                       The name matching is done in case-insensitive
                       manner.
                       The parameter must be delimited by a single
                       comma only and any white spaces are treated
                       as a part of protocol string.
                       Default: TLSv1.2,TLSv1.1,TLSv1.0

  SPDY:
    -c, --spdy-max-concurrent-streams=<NUM>
                       Set the maximum number of the concurrent
                       streams in one SPDY session.
                       Default: 100
    --frontend-spdy-window-bits=<N>
                       Sets the per-stream initial window size of
                       SPDY frontend connection to 2**<N>.
                       Default: 16
    --frontend-spdy-connection-window-bits=<N>
                       Sets the per-connection window size of SPDY
                       frontend connection to 2**<N>.
                       Default: 16
    --frontend-spdy-no-tls
                       Disable SSL/TLS on frontend SPDY
                       connections. SPDY protocol must be specified
                       using --frontend-spdy-proto. This option
                       also disables frontend HTTP/1.1.
    --frontend-spdy-proto
                       Specify SPDY protocol used in frontend
                       connection if --frontend-spdy-no-tls is
                       used. Default: spdy/3.1
    --backend-spdy-window-bits=<N>
                       Sets the per-stream initial window size of
                       SPDY backend connection to 2**<N>.
                       Default: 16
    --backend-spdy-connection-window-bits=<N>
                       Sets the per-connection window size of SPDY
                       backend connection to 2**<N>.
                       Default: 16
    --backend-spdy-no-tls
                       Disable SSL/TLS on backend SPDY connections.
                       SPDY protocol must be specified using
                       --backend-spdy-proto
    --backend-spdy-proto
                       Specify SPDY protocol used in backend
                       connection if --backend-spdy-no-tls is used.
                       Default: spdy/3.1

  Mode:
    -s, --spdy-proxy   Enable secure SPDY proxy mode.
    --spdy-bridge      Communicate with the backend in SPDY. Thus
                       the incoming SPDY/HTTPS connections are
                       converted to SPDY connection and relayed to
                       the backend. See --backend-http-proxy-uri
                       option if you are behind the proxy and want
                       to connect to the outside SPDY proxy.
    --client           Instead of accepting SPDY/HTTPS connection,
                       accept HTTP connection and communicate with
                       backend server in SPDY. To use shrpx as
                       a forward proxy, use -p option instead.
    -p, --client-proxy Like --client option, but it also requires
                       the request path from frontend must be
                       an absolute URI, suitable for use as a
                       forward proxy.

  Logging:
    -L, --log-level=<LEVEL>
                       Set the severity level of log output.
                       INFO, WARNING, ERROR and FATAL.
                       Default: WARNING
    --accesslog        Print simple accesslog to stderr.
    --syslog           Send log messages to syslog.
    --syslog-facility=<FACILITY>
                       Set syslog facility.
                       Default: daemon

  Misc:
    --add-x-forwarded-for
                       Append X-Forwarded-For header field to the
                       downstream request.
    --no-via           Don't append to Via header field. If Via
                       header field is received, it is left
                       unaltered.
    -D, --daemon       Run in a background. If -D is used, the
                       current working directory is changed to '/'.
    --pid-file=<PATH>  Set path to save PID of this program.
    --user=<USER>      Run this program as USER. This option is
                       intended to be used to drop root privileges.
    --conf=<PATH>      Load configuration from PATH.
                       Default: /etc/shrpx/shrpx.conf
    -v, --version      Print version and exit.
    -h, --help         Print this help and exit.

For those of you who are curious, shrpx is an abbreviation of "Spdy/https to Http Reverse ProXy".

Without any of -s, --spdy-bridge, -p and --client options, shrpx works as reverse proxy to the backend server:

Client <-- (SPDY, HTTPS) --> Shrpx <-- (HTTP) --> Web Server
                        [reverse proxy]

With -s option, it works as secure SPDY proxy:

Client <-- (SPDY, HTTPS) --> Shrpx <-- (HTTP) --> Proxy
                          [SPDY proxy]            (e.g., Squid)

The Client in the above is needs to be configured to use shrpx as secure SPDY proxy.

At the time of this writing, Chrome is the only browser which supports secure SPDY proxy. The one way to configure Chrome to use secure SPDY proxy is create proxy.pac script like this:

function FindProxyForURL(url, host) {
    return "HTTPS SERVERADDR:PORT";
}

SERVERADDR and PORT is the hostname/address and port of the machine shrpx is running. Please note that Chrome requires valid certificate for secure SPDY proxy.

Then run chrome with the following arguments:

$ google-chrome --proxy-pac-url=file:///path/to/proxy.pac --use-npn

Note

At the time of this writing, Chrome 24 limits the maximum concurrent connections to the proxy to 32. And due to the limitation of socket pool handling in Chrome, it is quickly filled up if SPDY proxy is used and many SPDY sessions are established. If it reaches the limit, the new connections are simply blocked until existing connections are timed out. (See Chrome Issue 92244). The workaround is make the number of maximum connections high, say, 99, which is the highest. To do this, you need to change so called Policy setup. See Policy Templates for details how to change Policy setup on the platform you use. The Policy name we are looking for is MaxConnectionsPerProxy For example, if you are using Linux, follow the instruction described in Linux Quick Start and create /etc/opt/chrome/policies/managed/test_policy.json file with the following content and restart Chrome:

{
    "MaxConnectionsPerProxy" :99
}

With --spdy-bridge, it accepts SPDY/HTTPS connections and communicates with backend in SPDY:

Client <-- (SPDY, HTTPS) --> Shrpx <-- (SPDY) --> Web or SPDY Proxy etc
                          [SPDY bridge]           (e.g., shrpx -s)

With -p option, it works as forward proxy and expects that the backend is secure SPDY proxy:

Client <-- (HTTP) --> Shrpx <-- (SPDY) --> Secure SPDY Proxy
                 [forward proxy]         (e.g., shrpx -s or node-spdyproxy)

The Client is needs to be configured to use shrpx as forward proxy.

In this configuration, clients which do not support secure SPDY proxy can use secure SPDY proxy through shrpx. Putting shrpx in the same box or same network with the clients, this configuration can bring the benefits of secure SPDY proxy to those clients. Since the maximum number of connections per server still applies in proxy connection, the performance gain is not obvious. For example, if the maximum number of connections per server is 6, after sending 6 requests to the proxy, client blocks further requests, which kills performance which might be gained in SPDY connection. For clients which can tweak these values (e.g., network.http.max-connections-per-server in Firefox), increasing them may improve the performance.

With --client option, it works as reverse proxy and expects that the backend is SPDY-enabled Web server:

Client <-- (HTTP) --> Shrpx <-- (SPDY) --> Web Server
                 [reverse proxy]

For the operation modes which talk to the backend in SPDY, the backend connections can be tunneled though HTTP proxy. The proxy is specified using --backend-http-proxy-uri option. The following figure illustrates the example of --spdy-bridge and --backend-http-proxy-uri option to talk to the outside SPDY proxy through HTTP proxy:

Client <-- (SPDY, HTTPS) --> Shrpx <-- (SPDY) --
                         [SPDY bridge]

        --===================---> SPDY Proxy
          (HTTP proxy tunnel)     (e.g., shrpx -s)

Examples

The examples directory contains a simple SPDY client implementation in C.

Python-Spdylay - Python Wrapper

The library comes with Python wrapper python-spdylay. See python directory.

spdylay's People

Contributors

acdha avatar alagoutte avatar chmac avatar irrenhaus avatar moparisthebest avatar piotrsikora avatar rgs1 avatar sebastianas avatar sludin avatar snnn avatar soyersoyer avatar szepeviktor avatar tatsuhiro-t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spdylay's Issues

Multi-core configuration

I am playing around shrpx. It works great, btw.

One of the config option is the number of the workers. I assume the master thread will create the specified number of workers, trying to situate each worker on a different core of cpu. The master thread then will distribute the traffic to each worker, in a "sticky" way of loan-balancing. Is that correct?

Some back-end servers do multi-threading in a similar way -- it seems to be a popular way these days. Each thread will listen on a dedicated port , e.g. Foreman, Squid.

It looks natural to align the shrpx's workers and the back-end server's workers, in order to avoid an additional dispatcher (in front of back-end servers).

Do you have suggestions on this?

2 way auth for shrpx

It would be useful to add 2 way auth for shrpx, in client mode, verify client side's certificate.

`shrpx --client-proxy' behind a transparent proxy

Moving from #31 .

In a following situation, where the client is behind a transparent proxy often seen in a corporate environment,

[ < client/chrome > <--> < proxy > ] <===> [ < shrpx > <--> < squid > ] ] <===> < google.com >

I think a possible solution is to let `shrpx --client-proxy' support a transparent proxy.

[ < client/chrome > <--> < shrpx --client-proxy > <--> < proxy > ] <===> [ < shrpx > <--> < squid > ] ] <===> < google.com >

What do you think?

python wrapper does not build

Hi,
I built spdylay client and so far working perfectly.
I am trying to build python bindings following the instruction python setup.py build_ext, I got the error that spdylay.c not find.
I grepped files under top root, could not find it either.
Any idea why spdylay.c is missing from the python directory ?

build error:

running build_ext
building 'spdylay' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c spdylay.c -o build/temp.macosx-10.7-intel-2.7/spdylay.o
i686-apple-darwin11-llvm-gcc-4.2: spdylay.c: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: no input files
i686-apple-darwin11-llvm-gcc-4.2: spdylay.c: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: no input files
lipo: can't figure out the architecture type of: /var/folders/hg/373yfnq53m37_3fldlg86hth1wcwgs/T//ccwvXIjn.out

Add support for basic authentication to shrpx

Hello, I want to setup shrpx at my VPS and access it through chrome from my desktop computer, so there must be some access restrict. I think http basic authentication maybe is the simplest way. Here is the document of spdy authentication: http://www.chromium.org/spdy/spdy-authentication

We should reply "407 Proxy Authentication Required" when the client didn't send "Proxy-Authenticate" header in the syn request, and the client then retries the request with a Proxy-Authorization header, and we will check the username and password whether they are correct.

it can not works as secure SPDY proxy

Hi,
I read the document and try to use "-s" let shrpx works as SPDY proxy but faild:

./shrpx -s /root/cert_test/ws1.key /root/cert_test/ws1.crt

I go to chrome and config the spdy proxy,I try to visit google but got a error:

502 Bad Gateway

shrpx spdylay/0.3.8 at port 3000

Client streams are not resetable

It is not possible to reset in progress streams from the client at the moment. The reason is that a client calls
spdylay_submit_request with some stream user data. The users callbacks get the stream user data to pass information to the client. However, the stream id is needed to call spdylay_submit_rst_stream.

I'm currently hacking around this by setting the stream id on my stream user data object in my request body callback and the syn_reply callback.

This means that for bodiless requests can't be cancelled between sending a request and getting the first control header for the response.

I think the solution would be to return the stream_id from submit_request.

check_response_header assert(3)s when mod_spdy pushes anything

When I point spdycat at a site using apache+mod_spdy, which pushes associated content, there is an invariable assert(3) in check_response_header() in the next frame (a SYN_HEADERS fram) after the SYN_REPLY frame which contains the requested body.

W/o associated content, it goes:

[ 0.256] NPN select next protocol: the remote server offers:
[ 0.386] send SYN_STREAM frame <version=3, flags=1, length=185>
[ 0.501] recv SETTINGS frame <version=3, flags=0, length=12>
[ 0.522] recv SYN_REPLY frame <version=3, flags=0, length=147>
[ 0.523] recv DATA frame (stream_id=1, flags=1, length=44)
[ 0.523] send GOAWAY frame <version=3, flags=0, length=8>
(last_good_stream_id=0)

With associated content (in this case pushing four images and one css), it goes:

[ 0.251] NPN select next protocol: the remote server offers:
[ 0.375] send SYN_STREAM frame <version=3, flags=1, length=183>
[ 0.490] recv SETTINGS frame <version=3, flags=0, length=12>
[ 0.493] recv SYN_STREAM frame <version=3, flags=2, length=74>
[ 0.494] recv SYN_STREAM frame <version=3, flags=2, length=33>
[ 0.494] recv SYN_STREAM frame <version=3, flags=2, length=29>
[ 0.494] recv SYN_STREAM frame <version=3, flags=2, length=24>
[ 0.605] recv SYN_STREAM frame <version=3, flags=2, length=25>
[ 0.606] recv SYN_REPLY frame <version=3, flags=0, length=141>
[ 0.606] recv DATA frame (stream_id=1, flags=1, length=1356)

and then assert(3)s, so the next fram (I presume a GOAWAY?) isn’t processed or reported.

I see that the lengths, as reported in the verbose output, of the SYN_STREAM frames are not indicative of the sizes of the associated files or of their URIs. I don’t know whether that is relevant.

Gdb tells me that check_response_header() is called with type=SPDYLAY_HEADERS,
frame is:

$5 = {ctrl = {hd = {version = 3, type = 8, flags = 0 '\000', length = 120}}, syn_stream = {
hd = {version = 3, type = 8, flags = 0 '\000', length = 120}, stream_id = 2,
assoc_stream_id = 6550624, pri = 0 '\000', slot = 0 '\000',
nv = 0x40aa25 <spdylay::recv_callback(spdylay_session*, unsigned char*, unsigned long, int, void*)+58>}, syn_reply = {hd = {version = 3, type = 8, flags = 0 '\000', length = 120},
stream_id = 2, nv = 0x63f460}, rst_stream = {hd = {version = 3, type = 8,
flags = 0 '\000', length = 120}, stream_id = 2, status_code = 6550624}, settings = {
hd = {version = 3, type = 8, flags = 0 '\000', length = 120}, niv = 6550624,
iv = 0x40aa25 <spdylay::recv_callback(spdylay_session*, unsigned char*, unsigned long, int, void*)+58>}, ping = {hd = {version = 3, type = 8, flags = 0 '\000', length = 120},
unique_id = 2}, goaway = {hd = {version = 3, type = 8, flags = 0 '\000', length = 120},
last_good_stream_id = 2, status_code = 6550624}, headers = {hd = {version = 3, type = 8,
flags = 0 '\000', length = 120}, stream_id = 2, nv = 0x63f460}, window_update = {hd = {
version = 3, type = 8, flags = 0 '\000', length = 120}, stream_id = 2,
delta_window_size = 6550624}, credential = {hd = {version = 3, type = 8, flags = 0 '\000',
length = 120}, slot = 2, proof = {data = 0x63f460 "\b\365c", length = 4237861},
certs = 0x14, ncerts = 140737488331984}}

If I add a return in the SYN_HEADERS if clause, it works and reports the headers and data frames of each of the associated URIs.

Examples fail to build

After a «make -k» to get everything which will build built, «make» reports:

Making all in examples
make[2]: Entering directory /home/cloos/src/spdylay-master/examples' g++-4.7.0 -DHAVE_CONFIG_H -I. -I.. -Wall -I./../lib/includes -I./../lib/includes -I/usr/kerberos/include -std=c++0x -O3 -ggdb3 -march=amdfam10 -floop-interchange -floop-strip-mine -floop-block -flto -fwhole-program -MT spdynative-spdylay_ssl.o -MD -MP -MF .deps/spdynative-spdylay_ssl.Tpo -c -o spdynative-spdylay_ssl.otest -f 'spdylay_ssl.cc' || echo './'`spdylay_ssl.cc
spdylay_ssl.cc: In member function ‘int spdylay::Spdylay::submit_request(const string&, const string&, uint8_t, void_)’:
spdylay_ssl.cc:120:19: error: unable to find string literal operator ‘operator"" SPDYLAY_VERSION’
make[2]: *_* [spdynative-spdylay_ssl.o] Error 1

shrpx forward proxy support?

I tried to use shrpx to forward proxy traffic, but without success. Backend is a Squid forward HTTP proxy, shrpx turn it into a SPDY proxy which Chrome browser supported.

Bring spdylay library in a custom program

Hi Tatsuhiro!
We would like to use you library in our program. We have a few problems while compiling the sources: all seems to work well but the "-a" option is disable beacause it says: "Warning: -a, --get-assets option cannot be used because
the binary was not compiled with libxml2."
Actually in our makefile we have included libxml2.. Do you have any suggestions?

Here's the makefile http://pastebin.com/1jhbPeFE

Add a spec for rpm packaging

Prefix: %{_usr}
Name: spdylay
Version: 0.3.3
Release: 1%{?dist}
Summary: The experimental SPDY protocol version 2 and 3 implementation in C

Group: System Environment/Libraries
License: MIT
URL: http://sourceforge.net/projects/spdylay/
Source0: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: pkgconfig >= 0.20, zlib >= 1.2.3, gcc, gcc-c++, make, openssl-devel, Cython

BuildRequires:

Requires:

%description
This is an experimental implementation of Google's SPDY protocol in C.
This library provides SPDY version 2 and 3 framing layer implementation. It does not
perform any I/O operations. When the library needs them, it calls the callback functions
provided by the application. It also does not include any event polling mechanism,
so the application can freely choose the way of handling events. This library code does
not depend on any particular SSL library (except for example programs which depend on
OpenSSL 1.0.1 or later).

%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%prep
%setup -q

%build
autoreconf -i
%{__automake}
%{__autoconf}
%configure --disable-static --enable-examples --disable-xmltest
%{__make} %{?_smp_mflags}

%{__make} html # needs python's 2.7 argparse

cython python/spdylay.pyx

%install
rm -rf $RPM_BUILD_ROOT
%{__make} install DESTDIR=$RPM_BUILD_ROOT

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc
%{libdir}/.so._
%exclude %{_libdir}/*.la

%files devel
%defattr(-,root,root,-)
%doc %{_docdir}/%{name}
%{_includedir}/*
%{libdir}/.so
%{libdir}/pkgconfig/.pc

%changelog

Support Gvent

May spdylay-python will support gevent?
Gevent has a monkey patch feature, which can convert a program from multi-threaded to multi-greenlet.So we will get a better performance.
Thanks.

Control/Data Flags not passed to send_callback in spdylay_session_send

https://github.com/tatsuhiro-t/spdylay/blob/master/lib/spdylay_session.c#L1528

In spdylay_session_send, send_callback always is passed flags set to 0, instead of the correct flags for the data or control frame.

Here is a quick patch:

int flags = (session->aob.item->frame_cat == SPDYLAY_CTRL) ?
spdylay_outbound_item_get_ctrl_frame(session->aob.item)->ctrl.hd.flags :
spdylay_outbound_item_get_data_frame(session->aob.item)->flags;
sentlen = session->callbacks.send_callback(session, data, datalen, flags,
session->user_data);

failmalloc test fails and exits with zero status

spdylay/tests$ ./failmalloc

 CUnit - A unit testing framework for C - Version 2.1-2
 http://cunit.sourceforge.net/

Suite: libspdylay_TestSuite
Test: failmalloc_session_send ...passed
Test: failmalloc_session_recv ...passed
Test: failmalloc_frame ...FAILED
1. spdylay_test_helper.c:49 - rv >= 0
2. spdylay_test_helper.c:49 - rv >= 0

Run Summary: Type Total Ran Passed Failed Inactive
suites 1 1 n/a 0 0
tests 3 3 2 1 0
asserts 4 4 2 2 n/a

Elapsed time = 0.003 seconds
jim@Jims-MacBook-Air:~/git/t0/spdylay/tests$ echo $?
0

This means that make check succeeds even though the test fails.

Timeout on spdycat does not work

No matter if I specify a timeout or not, or how long it is it does not time out and waits the network to fail (about 70-80 seconds).

shrpx client mode and haproxy's health check

Configured haproxy like below:

backend nas
mode http
option httpchk GET / HTTP/1.1\r\nHost:\ www
http-check expect rstatus 404|400|407
server test 127.0.0.1:89 #shrpx client

but when shrpx SPDY proxy server dead, client side still return 400 error code to haproxy, so the health check failed.

Is it correct to returen 5XX instead of 4XX when server side error, for example, server's shrpx or squid exit unexpected.

make error in centos5.5

./configure --prefix=/usr/local/spdylay OPENSSL_CFLAGS=-I/usr/local/ssl/include OPENSSL_LIBS="-L/usr/local/ssl/lib -lssl -lcrypto" LIBEVENT_OPENSSL_CFLAGS=-I/usr/local/libevent2/include LIBEVENT_OPENSSL_LIBS="-L/usr/local/libevent2/lib -lssl -lcrypto"

make

shrpx_listen_handler.o: In function shrpx::ListenHandler::create_worker_thread(unsigned int)': /root/src/spdylay-0.3.8/src/shrpx_listen_handler.cc:84: undefined reference tobufferevent_socket_new'
shrpx_listen_handler.o: In function shrpx::ListenHandler::accept_connection(int, sockaddr*, int)': /root/src/spdylay-0.3.8/src/shrpx_listen_handler.cc:111: undefined reference tobufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_listen_handler.cc:112: undefined reference to evbuffer_add' shrpx_client_handler.o: In functionshrpx::ClientHandler::get_pending_write_length()':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:293: undefined reference to bufferevent_get_output' shrpx_client_handler.o: In functionshrpx::ClientHandler::set_bev_cb(void ()(bufferevent, void_), void ()(bufferevent, void_), void ()(bufferevent, short, void_))':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:188: undefined reference to bufferevent_setcb' shrpx_client_handler.o: In function~ClientHandler':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:152: undefined reference to bufferevent_disable' /root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:153: undefined reference tobufferevent_free'
shrpx_client_handler.o: In function ClientHandler': /root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:131: undefined reference tobufferevent_enable'
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:132: undefined reference to bufferevent_setwatermark' /root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:131: undefined reference tobufferevent_enable'
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:132: undefined reference to bufferevent_setwatermark' shrpx_client_handler.o: In function~ClientHandler':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:152: undefined reference to bufferevent_disable' /root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:153: undefined reference tobufferevent_free'
shrpx_client_handler.o: In function shrpx::(anonymous namespace)::upstream_writecb(bufferevent_, void_)': /root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:56: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:56: undefined reference toevbuffer_get_length' shrpx_client_handler.o: In function shrpx::ClientHandler::get_pending_write_length()':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:294: undefined reference toevbuffer_get_length' shrpx_client_handler.o: In function shrpx::ClientHandler::set_upstream_timeouts(timeval const_, timeval const_)':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:194: undefined reference to bufferevent_set_timeouts' shrpx_client_handler.o: In functionshrpx::ClientHandler::get_evbase() const':
/root/src/spdylay-0.3.8/src/shrpx_client_handler.cc:181: undefined reference to bufferevent_get_base' shrpx_spdy_upstream.o: In functionshrpx::(anonymous namespace)::spdy_downstream_writecb(bufferevent_, void_)':
/root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:508: undefined reference to bufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:508: undefined reference toevbuffer_get_length'
shrpx_spdy_upstream.o: In function shrpx::(anonymous namespace)::recv_callback(spdylay_session_, unsigned char_, unsigned int, int, void_)': /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:80: undefined reference to bufferevent_get_input'
/root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:81: undefined reference toevbuffer_remove' shrpx_spdy_upstream.o: In function shrpx::(anonymous namespace)::send_callback(spdylay_session*, unsigned char const*, unsigned int, int, void*)':
/root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:57: undefined reference tobufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:59: undefined reference to evbuffer_get_length'
/root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:63: undefined reference toevbuffer_add' shrpx_spdy_upstream.o: In function shrpx::SpdyUpstream::on_downstream_body(shrpx::Downstream*, unsigned char const*, unsigned int)':
/root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:852: undefined reference toevbuffer_add' /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:859: undefined reference to evbuffer_get_length'
shrpx_spdy_upstream.o: In functionshrpx::(anonymous namespace)::spdy_data_read_callback(spdylay_session_, int, unsigned char_, unsigned int, int_, spdylay_data_source_, void_)': /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:675: undefined reference to evbuffer_remove'
shrpx_spdy_upstream.o: In functionshrpx::SpdyUpstream::error_reply(shrpx::Downstream_, int)': /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:705: undefined reference to evbuffer_add'
shrpx_spdy_upstream.o: In functionshrpx::(anonymous namespace)::spdy_downstream_eventcb(bufferevent_, short, void_)': /root/src/spdylay-0.3.8/src/shrpx_spdy_upstream.cc:531: undefined reference to bufferevent_getfd'
shrpx_https_upstream.o: In functionshrpx::(anonymous namespace)::https_downstream_writecb(bufferevent_, void_)': /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:459: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:459: undefined reference toevbuffer_get_length' shrpx_https_upstream.o: In function shrpx::HttpsUpstream::on_downstream_body_complete(shrpx::Downstream*)':
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:731: undefined reference tobufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:732: undefined reference to evbuffer_add'
shrpx_https_upstream.o: In functionshrpx::HttpsUpstream::on_downstream_body(shrpx::Downstream_, unsigned char const_, unsigned int)': /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:705: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:710: undefined reference toevbuffer_add' /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:715: undefined reference to evbuffer_add'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:720: undefined reference toevbuffer_add' shrpx_https_upstream.o: In function shrpx::HttpsUpstream::error_reply(int)':
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:568: undefined reference tobufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:569: undefined reference to evbuffer_add'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:569: undefined reference toevbuffer_add' shrpx_https_upstream.o: In function shrpx::(anonymous namespace)::https_downstream_readcb(bufferevent*, void*)':
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:427: undefined reference tobufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:427: undefined reference to evbuffer_get_length'
shrpx_https_upstream.o: In functionshrpx::HttpsUpstream::on_read()': /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:260: undefined reference to bufferevent_get_input'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:262: undefined reference toevbuffer_pullup' /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:264: undefined reference to evbuffer_get_length'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:270: undefined reference toevbuffer_get_length' /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:271: undefined reference to evbuffer_drain'
shrpx_https_upstream.o: In functionshrpx::HttpsUpstream::on_downstream_header_complete(shrpx::Downstream_)': /root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:689: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:690: undefined reference toevbuffer_add' shrpx_https_upstream.o: In function shrpx::(anonymous namespace)::htp_hdrs_completecb(http_parser_)':
/root/src/spdylay-0.3.8/src/shrpx_https_upstream.cc:179: undefined reference to bufferevent_write' shrpx_downstream.o: In functionshrpx::Downstream::init_response_body_buf()':
/root/src/spdylay-0.3.8/src/shrpx_downstream.cc:442: undefined reference to evbuffer_new' /root/src/spdylay-0.3.8/src/shrpx_downstream.cc:446: undefined reference toevbuffer_setcb'
shrpx_downstream.o: In function ~Downstream': /root/src/spdylay-0.3.8/src/shrpx_downstream.cc:71: undefined reference toevbuffer_free'
/root/src/spdylay-0.3.8/src/shrpx_downstream.cc:71: undefined reference to evbuffer_free' shrpx_http_downstream_connection.o: In functionshrpx::HttpDownstreamConnection::get_output_buffer_full()':
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:345: undefined reference to bufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:346: undefined reference toevbuffer_get_length'
shrpx_http_downstream_connection.o: In function ~HttpDownstreamConnection': /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:57: undefined reference tobufferevent_disable'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:58: undefined reference to bufferevent_free' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:57: undefined reference tobufferevent_disable'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:58: undefined reference to bufferevent_free' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:57: undefined reference tobufferevent_disable'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:58: undefined reference to bufferevent_free' shrpx_http_downstream_connection.o: In functionshrpx::HttpDownstreamConnection::on_read()':
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:443: undefined reference to bufferevent_get_input' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:444: undefined reference toevbuffer_pullup'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:448: undefined reference to evbuffer_get_length' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:450: undefined reference toevbuffer_drain'
shrpx_http_downstream_connection.o: In function shrpx::HttpDownstreamConnection::end_upload_data()': /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:263: undefined reference tobufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:264: undefined reference to evbuffer_add' shrpx_http_downstream_connection.o: In functionshrpx::HttpDownstreamConnection::push_upload_data_chunk(unsigned char const_, unsigned int)':
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:231: undefined reference to bufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:237: undefined reference toevbuffer_add'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:243: undefined reference to evbuffer_add' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:250: undefined reference toevbuffer_add'
shrpx_http_downstream_connection.o: In function shrpx::HttpDownstreamConnection::attach_downstream(shrpx::Downstream_)': /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:100: undefined reference to bufferevent_setwatermark'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:101: undefined reference tobufferevent_enable' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:105: undefined reference to bufferevent_setcb'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:110: undefined reference tobufferevent_set_timeouts' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:77: undefined reference to bufferevent_socket_new'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:82: undefined reference tobufferevent_socket_connect' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:84: undefined reference to bufferevent_free'
shrpx_http_downstream_connection.o: In functionshrpx::HttpDownstreamConnection::detach_downstream(shrpx::Downstream_)': /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:313: undefined reference to bufferevent_enable'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:314: undefined reference tobufferevent_setcb' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:319: undefined reference to bufferevent_set_timeouts'
shrpx_http_downstream_connection.o: In functionshrpx::HttpDownstreamConnection::push_request_headers()': /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:205: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:207: undefined reference toevbuffer_add' /root/src/spdylay-0.3.8/src/shrpx_http_downstream_connection.cc:220: undefined reference to bufferevent_set_timeouts'
shrpx_spdy_downstream_connection.o: In functionshrpx::SpdyDownstreamConnection::get_output_buffer_full()': /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:453: undefined reference to evbuffer_get_length'
shrpx_spdy_downstream_connection.o: In functionshrpx::(anonymous namespace)::spdy_data_read_callback(spdylay_session_, int, unsigned char_, unsigned int, int_, spdylay_data_source_, void_)': /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:180: undefined reference to evbuffer_remove'
/root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:198: undefined reference toevbuffer_get_length' shrpx_spdy_downstream_connection.o: In function shrpx::SpdyDownstreamConnection::init_request_body_buf()':
/root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:86: undefined reference toevbuffer_get_length' /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:86: undefined reference to evbuffer_drain'
/root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:91: undefined reference toevbuffer_new' /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:95: undefined reference to evbuffer_setcb'
shrpx_spdy_downstream_connection.o: In functionshrpx::SpdyDownstreamConnection::push_upload_data_chunk(unsigned char const_, unsigned int)': /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:365: undefined reference to evbuffer_add'
shrpx_spdy_downstream_connection.o: In function~SpdyDownstreamConnection': /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:63: undefined reference to evbuffer_free'
/root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:63: undefined reference toevbuffer_free' /root/src/spdylay-0.3.8/src/shrpx_spdy_downstream_connection.cc:63: undefined reference to evbuffer_free'
shrpx_spdy_session.o: In functionshrpx::SpdySession::notify()': /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:1144: undefined reference to bufferevent_write'
shrpx_spdy_session.o: In functionshrpx::SpdySession::clear_notify()': /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:1136: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:1137: undefined reference toevbuffer_get_length' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:1137: undefined reference to evbuffer_drain'
shrpx_spdy_session.o: In functionshrpx::(anonymous namespace)::recv_callback(spdylay_session_, unsigned char_, unsigned int, int, void_)': /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:659: undefined reference to bufferevent_get_input'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:660: undefined reference toevbuffer_remove' shrpx_spdy_session.o: In function shrpx::SpdySession::on_read_proxy()':
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:504: undefined reference tobufferevent_get_input' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:505: undefined reference to evbuffer_pullup'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:509: undefined reference toevbuffer_get_length' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:511: undefined reference to evbuffer_drain'
shrpx_spdy_session.o: In functionshrpx::SpdySession::unwrap_free_bev()': /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:465: undefined reference to bufferevent_getfd'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:466: undefined reference tobufferevent_free' shrpx_spdy_session.o: In function shrpx::(anonymous namespace)::send_callback(spdylay_session*, unsigned char const*, unsigned int, int, void*)':
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:636: undefined reference tobufferevent_get_output' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:638: undefined reference to evbuffer_get_length'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:642: undefined reference toevbuffer_add' shrpx_spdy_session.o: In function shrpx::SpdySession::init_notification()':
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:194: undefined reference tobufferevent_socket_new' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:204: undefined reference to bufferevent_socket_new'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:210: undefined reference tobufferevent_enable' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:211: undefined reference to bufferevent_setcb'
shrpx_spdy_session.o: In functionshrpx::SpdySession::disconnect()': /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:81: undefined reference to bufferevent_getfd'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:82: undefined reference tobufferevent_disable' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:83: undefined reference to bufferevent_free'
shrpx_spdy_session.o: In functionshrpx::(anonymous namespace)::writecb(bufferevent_, void_)': /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:230: undefined reference to bufferevent_get_output'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:230: undefined reference toevbuffer_get_length' shrpx_spdy_session.o: In function shrpx::(anonymous namespace)::proxy_eventcb(bufferevent*, short, void*)':
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:331: undefined reference tobufferevent_write' shrpx_spdy_session.o: In function shrpx::(anonymous namespace)::eventcb(bufferevent*, short, void*)':
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:257: undefined reference tobufferevent_getfd' shrpx_spdy_session.o: In function shrpx::SpdySession::initiate_connection()':
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:367: undefined reference tobufferevent_socket_new' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:368: undefined reference to bufferevent_enable'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:370: undefined reference tobufferevent_set_timeouts' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:374: undefined reference to bufferevent_setcb'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:378: undefined reference tobufferevent_socket_connect' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:441: undefined reference to bufferevent_free'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:415: undefined reference tobufferevent_openssl_socket_new' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:427: undefined reference to bufferevent_socket_connect'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:446: undefined reference tobufferevent_setwatermark' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:447: undefined reference to bufferevent_enable'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:448: undefined reference tobufferevent_setcb' /root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:431: undefined reference to bufferevent_socket_new'
/root/src/spdylay-0.3.8/src/shrpx_spdy_session.cc:423: undefined reference tobufferevent_socket_new' shrpx_io_control.o: In function shrpx::IOControl::force_resume_read()':
/root/src/spdylay-0.3.8/src/shrpx_io_control.cc:69: undefined reference tobufferevent_enable' shrpx_io_control.o: In function shrpx::IOControl::resume_read(shrpx::IOCtrlReason)':
/root/src/spdylay-0.3.8/src/shrpx_io_control.cc:57: undefined reference tobufferevent_enable' shrpx_io_control.o: In function shrpx::IOControl::pause_read(shrpx::IOCtrlReason)':
/root/src/spdylay-0.3.8/src/shrpx_io_control.cc:48: undefined reference tobufferevent_disable' shrpx_ssl.o: In function shrpx::ssl::accept_connection(event_base*, ssl_ctx_st*, int, sockaddr*, int)':
/root/src/spdylay-0.3.8/src/shrpx_ssl.cc:278: undefined reference tobufferevent_openssl_socket_new' /root/src/spdylay-0.3.8/src/shrpx_ssl.cc:280: undefined reference to bufferevent_socket_new'
shrpx_thread_event_receiver.o: In functionshrpx::ThreadEventReceiver::on_read(bufferevent_)': /root/src/spdylay-0.3.8/src/shrpx_thread_event_receiver.cc:46: undefined reference to bufferevent_get_input'
/root/src/spdylay-0.3.8/src/shrpx_thread_event_receiver.cc:47: undefined reference toevbuffer_get_length' /root/src/spdylay-0.3.8/src/shrpx_thread_event_receiver.cc:49: undefined reference to evbuffer_remove'
/root/src/spdylay-0.3.8/src/shrpx_thread_event_receiver.cc:59: undefined reference tobufferevent_get_base' shrpx_worker.o: In function shrpx::Worker::run()':
/root/src/spdylay-0.3.8/src/shrpx_worker.cc:74: undefined reference toevent_base_new' /root/src/spdylay-0.3.8/src/shrpx_worker.cc:76: undefined reference to bufferevent_socket_new'
/root/src/spdylay-0.3.8/src/shrpx_worker.cc:85: undefined reference tobufferevent_enable' /root/src/spdylay-0.3.8/src/shrpx_worker.cc:86: undefined reference to bufferevent_setcb'
/root/src/spdylay-0.3.8/src/shrpx_worker.cc:88: undefined reference toevent_base_loop' shrpx.o: In function shrpx::(anonymous namespace)::create_evlistener(shrpx::ListenHandler_, int)':
/root/src/spdylay-0.3.8/src/shrpx.cc:165: undefined reference to evutil_make_socket_nonblocking' /root/src/spdylay-0.3.8/src/shrpx.cc:209: undefined reference toevconnlistener_new'
/root/src/spdylay-0.3.8/src/shrpx.cc:210: undefined reference to evconnlistener_set_error_cb' shrpx.o: In functionshrpx::(anonymous namespace)::event_loop()':
/root/src/spdylay-0.3.8/src/shrpx.cc:238: undefined reference to event_base_new' /root/src/spdylay-0.3.8/src/shrpx.cc:283: undefined reference toevent_base_loop'
/root/src/spdylay-0.3.8/src/shrpx.cc:285: undefined reference to evconnlistener_free' /root/src/spdylay-0.3.8/src/shrpx.cc:288: undefined reference toevconnlistener_free'
collect2: ld returned 1 exit status
make[2]: *** [shrpx] Error 1
make[2]: Leaving directory /root/src/spdylay-0.3.8/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/root/src/spdylay-0.3.8'
make: *** [all] Error 2

spdylay.h missing sys/types.h

diff --git a/lib/includes/spdylay/spdylay.h b/lib/includes/spdylay/spdylay.h
index d71cbb7..178bd5e 100644
--- a/lib/includes/spdylay/spdylay.h
+++ b/lib/includes/spdylay/spdylay.h
@@ -31,6 +31,7 @@ extern "C" {

#include <stdlib.h>
#include <stdint.h>
+#include <sys/types.h>

struct spdylay_session;
typedef struct spdylay_session spdylay_session;

configure error

Hi tatsuhiro-t,

I'm trying to compile spdylay on ubuntu 11.10, and I'm getting this error then running ./configure:

checking whether g++ accepts -g... no
checking dependency style of g++... none
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
./configure: line 15706: syntax error near unexpected token 0.20' ./configure: line 15706:PKG_PROG_PKG_CONFIG(0.20)'

Michael

does not build for mac lion

I have installed pkg-config with brew install pkg-config.
pkg-config-0.27 already installed
pkgconfig @0.27 devel/pkgconfig

checking whether make sets $(MAKE)... (cached) yes
./configure: line 15729: syntax error near unexpected token 0.20' ./configure: line 15729:PKG_PROG_PKG_CONFIG(0.20)'

Add API to manually send WINDOW_UPDATE frame

The current implementation automatically sends back WINDOW_UPDATE after certain amount of DATA are received.
This works fine for endpoint like web-server or browser but it is not desirable for proxy, because it may want to send WINDOW_UPDATE after it relayed the data to the opposite endpoint. For this purpose, we need manual sending of WINDOW_UPDATE.

spdylay client submit reset frame after about 200 push streams

During my stress test, I continuously push data to spdy client.
After about 200 pushes, spdylay client sends reset frame to the server.

This is consistently happen for several tests.

on data chunk recv: stream id 203
before control frame send: frame type: 3 // SPDYLAY_RST_STREAM = 3,

Is there a hard code setting on the max push streams ?

build error on ubuntu 10.04 (lucid)

/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I./includes -I./includes -Wall -g -O2 -MT spdylay_session.lo -MD -MP -MF .deps/spdylay_session.Tpo -c -o spdylay_session.lo spdylay_session.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I./includes -I./includes -Wall -g -O2 -MT spdylay_session.lo -MD -MP -MF .deps/spdylay_session.Tpo -c spdylay_session.c -fPIC -DPIC -o .libs/spdylay_session.o
In file included from spdylay_session.c:25:
spdylay_session.h:123: error: redefinition of typedef 'spdylay_session'
./includes/spdylay/spdylay.h:36: note: previous declaration of 'spdylay_session' was here
spdylay_session.c: In function 'spdylay_outbound_item_free':
spdylay_session.c:133: warning: enumeration value 'SPDYLAY_SETTINGS' not handled in switch
spdylay_session.c: In function 'spdylay_session_add_frame':
spdylay_session.c:198: warning: enumeration value 'SPDYLAY_SETTINGS' not handled in switch
spdylay_session.c: In function 'spdylay_session_after_frame_sent':
spdylay_session.c:541: error: 'CLOCK_MONOTONIC_RAW' undeclared (first use in this function)
spdylay_session.c:541: error: (Each undeclared identifier is reported only once
spdylay_session.c:541: error: for each function it appears in.)
spdylay_session.c:478: warning: enumeration value 'SPDYLAY_SETTINGS' not handled in switch
spdylay_session.c: In function 'spdylay_session_on_ping_received':
spdylay_session.c:872: error: 'CLOCK_MONOTONIC_RAW' undeclared (first use in this function)
make[3]: *** [spdylay_session.lo] Error 1
make[3]: Leaving directory /home/gdewan/tatsuhiro-t-spdylay-826cd6a/lib' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory/home/gdewan/tatsuhiro-t-spdylay-826cd6a/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gdewan/tatsuhiro-t-spdylay-826cd6a'
make: *** [all] Error 2
gdewan@sfo-lpwng:~/tatsuhiro-t-spdylay-826cd6a$

Incorrect test for event.udata being intptr_t

On OS X with gcc == i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 the following code check for event.udata being an intptr_t:


#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>

int
main ()
{
  struct kevent event;
  event.udata = (intptr_t*)(&event);
  ;
  return 0;
}

I believe the proper check should be:

event.udata = (intptr_t)(&event);

Or something similar. The current check as written passes when event.udata us a void*.

In EventPoll_kqueue.cc the following #ifdef block is used:

#ifdef KEVENT_UDATA_INTPTR_T
# define PTR_TO_UDATA(X) (reinterpret_cast<intptr_t>(X))
#else // !KEVENT_UDATA_INTPTR_T
# define PTR_TO_UDATA(X) (X)
#endif // !KEVENT_UDATA_INTPTR_T

Since KEVENT_UDATA_INTPTR_T is set to 1 by the configure check, the:

PTR_TO_UDATA(user_data)

in update_event becomes:

reinterpret_cast<intptr_t>(user_data)

And results in the following error:

error: invalid conversion from ‘intptr_t’ to ‘void*’

shrpx with fast chunked backend and slow frontent connection

I've been toying with shrpx, and I think it's great, but I've run into an issue. I have backend server with a fast HTTP connection to shrpx, and it always sends chunked data. The connection on the frontend (which is SPDY) is much slower.

The client successfully connects to the server, starts downloading data, but it halts after a while (with stream reset). Here's what I see in verbose mode:

$ ./spdylay/src/spdycat -nv -3 --window-bits=16 -H 'Host: www.origo.hu' 'http://localhost:5555/index.html'
[  0.205] NPN select next protocol: the remote server offers:
          * spdy/3
          * spdy/2
          * http/1.1
          NPN selected the protocol: spdy/3
[  0.318] recv SETTINGS frame <version=3, flags=0, length=20>
          (niv=2)
          [4(0):100]
          [7(0):32]
[  0.318] send SETTINGS frame <version=3, flags=0, length=12>
          (niv=1)
          [7(0):65536]
[  0.318] send SYN_STREAM frame <version=3, flags=1, length=228>
          (stream_id=1, assoc_stream_id=0, pri=3)
          :host: www.origo.hu
          :method: GET
          :path: /index.html
          :scheme: http
          :version: HTTP/1.1
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: spdylay/0.3.8-DEV
[  0.483] recv SYN_REPLY frame <version=3, flags=0, length=247>
          (stream_id=1)
          :status: 200 OK
          :version: HTTP/1.1
          content-type: text/html
          date: Wed, 27 Feb 2013 17:04:33 GMT
          pragma: no-cache
          server: Apache
          set-cookie: axelero=SLFDJLVENJJGGENGMPNLHFOTIHLLGRQTLELJGTIRPHKBDFADCIIFHMPNPAHMKJGQHIMTCCSHRBDFADCIIFHBDFADCIIFH;path=/;domain=.origo.hu;expires=Thu, 31-Dec-2015 23:59:59 GMT
          x-ua-compatible: IE=edge,chrome=1
[  0.485] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.485] recv DATA frame (stream_id=1, flags=0, length=1067)
[  0.507] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.583] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.613] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.613] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.613] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.648] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.648] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.690] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.690] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.690] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.718] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.718] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.718] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.754] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.754] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.754] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.790] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.790] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.790] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.837] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.837] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.837] send WINDOW_UPDATE frame <version=3, flags=0, length=8>
          (stream_id=1, delta_window_size=32923)
[  0.858] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.858] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.858] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.902] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.902] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.902] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.938] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.938] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.938] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.969] recv DATA frame (stream_id=1, flags=0, length=1448)
[  0.969] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.011] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.011] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.011] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.045] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.045] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.045] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.080] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.080] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.080] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.113] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.113] recv DATA frame (stream_id=1, flags=0, length=1448)
[  1.113] recv DATA frame (stream_id=1, flags=0, length=757)
[  1.113] recv RST_STREAM frame <version=3, flags=0, length=8>
          (stream_id=1, status_code=6)
[  1.114] send GOAWAY frame <version=3, flags=0, length=8>
          (last_good_stream_id=0)

The log on the server:

$ ./spdylay/src/shrpx --spdy-proxy --no-via --log-level=INFO -b 127.0.0.1,3333 -f 0.0.0.0,5555 --private-key-passwd-file=../keys/www.spdy.hu.key.password --spdy-max-concurrent-streams=100 ../keys/www.spdy.hu.key ../keys/www.spdy.hu.crt

[INFO] Resolving backend address
       (shrpx.cc:904)
[INFO] Address resolution for 127.0.0.1 succeeded: 127.0.0.1
       (shrpx.cc:105)
[INFO] Unable to get IPv6 address for 0.0.0.0: Address family for hostname not supported
       (shrpx.cc:148)
[INFO] Listening on 0.0.0.0, port 5555
       (shrpx.cc:186)
[INFO] Entering event loop
       (shrpx.cc:281)
[INFO] [LISTEN:0x2589320] Accepted connection. fd=7
       (shrpx_listen_handler.cc:97)
[INFO] [CLIENT_HANDLER:0x2587f40] SSL/TLS handleshake completed
       (shrpx_client_handler.cc:103)
[INFO] [CLIENT_HANDLER:0x2587f40] The negotiated next protocol: spdy/3
       (shrpx_client_handler.cc:205)
[INFO] [UPSTREAM:0x259fa20] Received upstream SYN_STREAM stream_id=1
       (shrpx_spdy_upstream.cc:147)
[INFO] [UPSTREAM:0x259fa20] HTTP request headers. stream_id=1
:host: www.origo.hu
:method: GET
:path: /index.html
:scheme: http
:version: HTTP/1.1
accept: */*
accept-encoding: gzip, deflate
user-agent: spdylay/0.3.8-DEV
       (shrpx_spdy_upstream.cc:201)
[INFO] [CLIENT_HANDLER:0x2587f40] Downstream connection pool is empty. Create new one
       (shrpx_client_handler.cc:272)
[INFO] [DCONN:0x259ec50] Attaching to DOWNSTREAM:0x25a0270
       (shrpx_http_downstream_connection.cc:70)
[INFO] [DCONN:0x259ec50] Connecting to downstream server
       (shrpx_http_downstream_connection.cc:89)
[INFO] [DCONN:0x259ec50] HTTP request headers. stream_id=1
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: spdylay/0.3.8-DEV
Host: www.origo.hu
X-Forwarded-Proto: http
       (shrpx_http_downstream_connection.cc:202)
[INFO] [DCONN:0x259ec50] Connection established. stream_id=1
       (shrpx_spdy_upstream.cc:514)
[INFO] [DOWNSTREAM:0x25a0270] HTTP response header completed
       (shrpx_spdy_upstream.cc:769)
[INFO] [UPSTREAM:0x259fa20] HTTP response headers. stream_id=1
:status: 200 OK
:version: HTTP/1.1
server: Apache
set-cookie: axelero=SLFDJLVENJJGGENGMPNLHFOTIHLLGRQTLELJGTIRPHKBDFADCIIFHMPNPAHMKJGQHIMTCCSHRBDFADCIIFHBDFADCIIFH;path=/;domain=.origo.hu;expires=Thu, 31-Dec-2015 23:59:59 GMT
content-type: text/html
pragma: no-cache
x-ua-compatible: IE=edge,chrome=1
date: Wed, 27 Feb 2013 17:06:29 GMT
       (shrpx_spdy_upstream.cc:810)
[INFO] [DOWNSTREAM:0x25a0270] HTTP response completed
       (shrpx_spdy_upstream.cc:860)
[INFO] [DCONN:0x259ec50] EOF. stream_id=1
       (shrpx_spdy_upstream.cc:526)
[INFO] [UPSTREAM:0x259fa20] RST_STREAM stream_id=1
       (shrpx_spdy_upstream.cc:625)
[INFO] [UPSTREAM:0x259fa20] Stream stream_id=1 is being closed
       (shrpx_spdy_upstream.cc:99)
[INFO] [DOWNSTREAM:0x25a0270] Deleting
       (shrpx_downstream.cc:67)
[INFO] [DOWNSTREAM:0x25a0270] Deleted
       (shrpx_downstream.cc:77)
[INFO] [UPSTREAM:0x259fa20] No more read/write for this SPDY session
       (shrpx_spdy_upstream.cc:393)
[INFO] [CLIENT_HANDLER:0x2587f40] Deleting
       (shrpx_client_handler.cc:147)
[INFO] [CLIENT_HANDLER:0x2587f40] Deleted
       (shrpx_client_handler.cc:165)

The successfully downloaded data is exactly 65536 bytes which is strange. I think it has to something with buffering... If I change window size on the client, the downloaded size changes, but never reaches the full file size, which is 89460 (even when it is set to 30).

When the backend link is slower, say I change the delay from 10ms to 50ms (it is simulated on localhost) then the problem goes away. When my backend server sends the whole content in one big chunk, the problem goes away again.

I do have a pcap trace as well, I uploaded it here: https://docs.google.com/file/d/0Bzj2UbMqUIfrRGdXZVZLRjFUdmc/edit?usp=sharing

Timeout Config for Long-Pulling Sessions

First, thanks for writing the C library, which is very efficient compared to libraries in higher-level languages.

I wonder what are your thoughts on the timeout config for the long-pulling websites, when used as a forward proxy.

When browsing G+, I did experience hanging on a certain requests. Then the website won't respond to my subsequent clicks on other links, unless I reload the webpage. Not sure if related.

segfault in spdylay_gzip_inflate

Inside callback of on_data_chunk_recv_callback(),
retrieve request handler
req = spdylay_session_get_stream_user_data(session, stream_id);

My Request never sets gzip inflater; (double check by comment out spdylay_gzip_inflate_new();

However, after several msg exchanges, the req->inflater is not null and caused segfault inside spdylay_gzip_inflate;

Looks like some wired memory issues inside spdylay session.

(gdb) bt
#0 spdylay_gzip_inflate (inflater=0x534b6d3658377441, out=0x7ffff6ba7b80 "Basic eGn0ms0s8fyCVbQgZ_19F2w5tjAt7X6mKS7BXh3iIjMF4ycpFHdJpI3tQqQtkoBIvE_nDjDqMRdow-46i27omQ==",

outlen_ptr=0x7ffff6ba7b68, 
in=0x7ffff6ba8c88 "push ack success,\"data\":\"hello client: eGn0ms0s8fyCVbQgZ_19F2w5tjAt7X6mKS7BXh3iIjMF4ycpFHdJpI3tQqQtkoBIvE_nDjDqMRdow-46i27omQ== : mcBamw-jkLeDRnZS83GfF9Cy7aM= : u-server : u-worker : undefined\"}", inlen_ptr=0x7ffff6ba7b70) at spdylay_gzip.c:63

#1 0x0000000000403f1d in on_data_chunk_recv_callback (session=0x7ffff001ac20, flags=, stream_id=7,

data=0x7ffff6ba8c88 "push ack success,\"data\":\"hello client: eGn0ms0s8fyCVbQgZ_19F2w5tjAt7X6mKS7BXh3iIjMF4ycpFHdJpI3tQqQtkoBIvE_nDjDqMRdow-46i27omQ== : mcBamw-jkLeDRnZS83GfF9Cy7aM= : u-server : u-worker : undefined\"}", len=16, user_data=<optimized out>) at spdycli.c:734

#2 0x00007ffff75ae0ea in spdylay_session_mem_recv (session=0x7ffff001ac20, in=0x7ffff6ba8c80 "", inlen=) at spdylay_session.c:2631
#3 0x00007ffff75aeac9 in spdylay_session_recv (session=0x7ffff001ac20) at spdylay_session.c:2685
#4 0x00000000004039b4 in exec_io (connection=) at spdycli.c:1087
#5 initSpdySession (pthrduri=) at spdycli.c:1235
#6 0x000000000040463d in createSpdyClient (arg=0x620990) at spdycli.c:1132
#7 0x00007ffff738de9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#8 0x00007ffff70bb4bd in clone () from /lib/x86_64-linux-gnu/libc.so.6
#9 0x0000000000000000 in ?? ()

wrong format passed to printf

int spdylay_ssl.cc:

void print_timer()
{
  timeval tv;
  get_timer(&tv);
  printf("%s[%3ld.%03ld]%s",
         ansi_esc("\033[33m"),
         tv.tv_sec, tv.tv_usec/1000,
         ansi_escend());
}

The type of "tv.tv_usec" is suseconds_t, in some platform(e.g.Linux) it is 8 bytes and some platform(e.g. Mac OS X) it is 4 bytes.

#include <iostream>
#include <sys/time.h>

#include <typeinfo>
#include <cxxabi.h>
#include <stdlib.h>



int main(){
  std::cout<<"sizeof(suseconds_t)="<<sizeof(suseconds_t)<<std::endl;

  int status;
  char *realname = abi::__cxa_demangle(typeid(suseconds_t).name(), 0, 0, &status);
  std::cout<<realname<<std::endl;
  free(realname);
  return 0;
}

$ clang++ -o t test.cpp
$ ./t
sizeof(suseconds_t)=4
int
$ file t
t: Mach-O 64-bit executable x86_64

spdy client without TSL

Hi,

I have a testing task using spdy for comparison, for efficiency consideration, I should use spdy without ssl, could anyone tell me how to disable the TSL in the client? Your help is greatly appreciated.

BR

Unable to build Python extension module (spdylay.c: No such file or directory)

I compiled and installed Spdylay library (in the standard location) with success, I'm also able to compile the examples and custom programs, but when I try to build the Python extension module I get:

$ python setup.py build_ext
running build_ext
building 'spdylay' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c spdylay.c -o build/temp.linux-x86_64-2.7/spdylay.o
gcc: error: spdylay.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 4

And indeed spdylay.c is not in that folder and neither in my whole file system (including this repo).

shrpx does not send entire certificate chain?

I've been testing shrpx with Chrome and Firefox, and Firefox is complaining about the SSL certificate. From what I can understand, shrpx appears not to be sending the full certificate chain (even though I've pointed it to a file where I concatenated the site certificate, the intermediate certificate and the ca certificate).

What I can see in Firefox is that it receives the site certificate only.

Do I need to do anything special to get this to work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.