Don't do 'delete this' in HTTPTransaction

Summary: 'delete this' is a risky pattern. A safer pattern is to use vector/map as one composes lifteimes. Since HTTPSession always outlives all the transactions it comprises, this is a safe change. We have a check in the destructor of HTTPSession already to make sure this vector is empty when the class is destroyed as well.

Test Plan: unit tests with ASAN enabled, will canary

Reviewed By: afrind@fb.com

Subscribers: trunkagent, doug, bmatheny

FB internal diff: D1686512

Signature: t1:1686512:1416444507:1653e423eaedc9e8720959b63efda947ef1e3b30
add an event field type indicating cache persistence

Summary: need this field to indicate persistence

Test Plan: build httpclient

Reviewed By: benyluo@fb.com

Subscribers: doug, bmatheny, seanc

FB internal diff: D1693237

Signature: t1:1693237:1416454114:7d6abcebd4731e701e6580a74d9d25bbf7e20054
Convert static TransitionTable to union

Summary:
Due to iOS calling exit() using global statics that are
nontrivial is unsafe. This is the most common related crash so fix this
one.

Test Plan: fbmake runtests, tested basic functionality on iOS and Android devices

Reviewed By: dcsommer@fb.com

Subscribers: trunkagent, cgheorghe, aansari, nspiegelberg, bmatheny, seanc, shikong, fma, kmdent, dancol, ranjeeth

FB internal diff: D1691109

Tasks: 5405813

Signature: t1:1691109:1416438374:cebdf5739ec8285ac90a4669f790836b10218278
Remove Chromium workaround for shutdown

Summary:
We're at 0.305% of traffic being affected by this diff right now
(https://fburl.com/18717764), and it only happens during shutdown, which is
relatively rare. I think we can just pull the trigger here and make the
code a little less complex.

Test Plan: tests

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1694100

Tasks: 4073013

Signature: t1:1694100:1416512113:bf06106d55ac97f6cf7f6b27ad7dff540b4225ad
Save some space in SPDYCodec

Summary: This saves some space, by using bitfields.

Test Plan: unit tests

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1694129

Signature: t1:1694129:1416512540:b6dfd7725770ac6cc872f651034018d43f8b5e12
Make GzipHeaderCodec exit()-safe

Summary:
Use placement new with a union to avoid having the IOBuf's
destructor called.

Test Plan: fbmake runtests

Reviewed By: dcsommer@fb.com

Subscribers: ranjeeth, subodh, bmatheny, cgheorghe, kmdent, fma, pgriess, shikong

FB internal diff: D1693869

Tasks: 5405529

Signature: t1:1693869:1416506581:58a79fbcea36798b53ee8d644337b9c2f016b19b
Use enum for read/write state

Summary:
This is less error prone and avoids the possibility of
considering a socket as unpaused/useful while it is shutdown.

Test Plan: unit tests

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1694298

Signature: t1:1694298:1416512447:d31b999a7ed062c36a02961c571a791d8cad764b
AsyncTimeoutSet lives in proxygen now

Summary:
This is deprecated in favor of HHWheelTimer now. In the meantime,
take the code into proxygen since we are the last major user.

Test Plan: unit tests

Reviewed By: davejwatson@fb.com

Subscribers: hphp-diffs@, ps, kparton, jdperlow, fugalh, cgheorghe, trunkagent, doug, fbcode-common-diffs@, davejwatson, andrewcox, atlas2-eng@, alandau, bmatheny, alikhtarov, mshneer

FB internal diff: D1677319

Tasks: 5485692

Signature: t1:1677319:1415833221:a4e97ecf1ca20537d8d5248a03d692929263af09
Remove unneeded include

Summary: Don't need this.

Test Plan: compiled

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1697674

Signature: t1:1697674:1416598652:abaac8248fec9a392e80fdabb99f9b7bfc5674a1
Pass separator to HTTPHeader::combine

Summary: For cookies

Test Plan: unit tests, used in a later diff

Reviewed By: viswanath@fb.com

Subscribers: trunkagent, doug, bmatheny

FB internal diff: D1706662

Signature: t1:1706662:1417038239:2cac056c5542010794ac62b353a19152108cecdc
Handle SETTINGS_HEADER_TABLE_SIZE

Summary:
Update the codec when the peer changes the table size.  Also emit a context update on the next header generation.

Facebook: This is not the cleanest OSS split one could have envisioned, but all the HTTP2 changes will be public soon enough.

Test Plan: Added some tests, need a more explicit test for the encoder/decoder changes, but have to wait until a different diff lands

Reviewed By: cgheorghe@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1692745

Signature: t1:1692745:1417463981:f67560d39d9d1eec70801749cdffab2fc2936ae1
connection preface support

Summary:
HTTP/2 has a little exchange prior to any frames which is supposedly guarateed to cause an error if the other end missed the ALPN/NPN memo and is actually parsing HTTP/1.x.  Add the required virtual methods to HTTPCodec/HTTPSession.

Facebook:
Implemented the HTTP/2 parts

Test Plan: Unit tests

Reviewed By: praveenr@fb.com

Subscribers: trunkagent, doug, bmatheny

FB internal diff: D1704830

Signature: t1:1704830:1417468739:b14986903ac15f1167c48db4a5b1b680b484da98
prevent overflow in variable-length encoding for integers

Summary: prevent a situation where a client could send an unbounded encoding for an integer

Test Plan: unit test

Reviewed By: afrind@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1701218

Tasks: 4193845

Signature: t1:1701218:1416878431:023473b6df39ead2d9b5f9dc9802bdc8e53ef15b
enforce limit on literal size to 96KB

Summary: this covers the case when a client could send a huge literal value

Test Plan: unit test and pushed everywhere with proxygen:383 - rolled back after we saw an increase in HPACK errors

Reviewed By: afrind@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1702162

Tasks: 4193845

Signature: t1:1702162:1417466691:36bc8651e860d9df2a670b9b0097a3ae8f622e0c
log decoder header table in case of decode errors

Summary: we've got a really low number of sporadic decode errors after enabling HPACK in prod everywhere. Logging the decoder state might give a lot of hints of what's going on and we need in prod since the errors are sporadic and canaries won't catch them.

Test Plan: ran tests - the tests causing errors are spitting logs

Reviewed By: afrind@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1709826

Tasks: 5714696

Signature: t1:1709826:1417466834:0f407860671576ef87889dbc1a2763426a0cfe5c
bugfix for build break in HPACKCodec

Summary: I shuffled some commits when rebasing and missed this

Test Plan: compiled tests

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny, cgheorghe

FB internal diff: D1711057

Signature: t1:1711057:1417474882:2a85829ecbb8f4e1407378e5603e5262b530ec0e
Reverse static/dynamic indexes

Summary: Doing this in stages to make changes digestable.  In HPACK/9 the 'global' index space is <static table>|<dynamic table>, which is the opposite of earlier drafts

Test Plan: unit tests

Reviewed By: cgheorghe@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1697677

Signature: t1:1697677:1417469033:c65ca63c02fd8aae15f06f562f4b5dd4db9ce945
Fix deps in Dockerfile

Summary:
Missing cmake and build-essential dependencies in the current dockerfile in order to be able to compile: double-conversion
Closes https://github.com/facebook/proxygen/pull/24
Github Author: Cedric Lamoriniere <cedric.lamoriniere@gmail.com>

{sync, type="child", parent="github", parentrepo="facebook/proxygen", parentprnum="24", parentprfbid="734320296638206"}

Test Plan: Imported from GitHub, without a `Test Plan:` line.

Reviewed By: praveenr@fb.com

Subscribers: bmatheny

FB internal diff: D1710077

Signature: t1:1710077:1417458845:9bfccf661f8b5370c78a2dde1d82bd03e63f5e71
Bump version to 5:0
Do not close socket before detaching transaction

Summary:
Following up on https://phabricator.fb.com/D1707999.

Shutdown test was failing because interchanging the order of
sock_->closeWithReset() and onError callbacks () resulted in
sock_->closeNow() being called due to onError() -> ~CallbackGuard() ->
HTTPSession::detach() -> HTTPSession::checkForShutdown(). This is fixed
now.

Found another similar scenario in shutdownTransport() where we could
close the socket before onError()/detachTransaction callbacks.

I looked into the other solution of lazily copying the necessary info,
but to do that within handler's detachTransaction, we need to anyway
ensure that the socket is not closed until detachTransaction(). The
other option is to do the lazy copy within HTTPSession, but that doesn't
seem ideal given this is only for logging, and most of the copied info
will anyway be wasted due to sampling.

Either way, I feel it's a good approach to ensure that the socket is not
closed until the transaction is detached.

Test Plan: fbmake runtests --extended, will update with canary results.

Reviewed By: afrind@fb.com

Subscribers: trunkagent, bmatheny, praveenr, ajitb

FB internal diff: D1712415

Signature: t1:1712415:1417549423:77b29c6497256f601394313edaf245bf6d42c2b8