Remove dependency on concurrency/Util.h

Summary:
Another thrift dependency we don't need. I think a lot of
these unit tests that I had to modify shouldn't be dealing with timing/raw
bytes (instead using a mock codec), but that's way out of scope right now.

Test Plan: unit tests

Reviewed By: viswanath@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1667979

Signature: t1:1667979:1415734260:644724bf520de781ac5e8a0fab3f649e02baa1ed
Codemod: use angle brackets

Summary:
Now that proxygen is an installed library, it should use angle
brackets to include itself, like thrift and folly.

Test Plan: unit tests

Reviewed By: viswanath@fb.com

Subscribers: doug, jdperlow, snaptu-diffs@, bmatheny, nimishshah, louisk, cgheorghe

FB internal diff: D1672948

Signature: t1:1672948:1415735707:c8fee22fca0c4cbf3cb86f52f9ac5780ae8c0a46
Update proxygen-style.py

Summary:
Per
https://our.intern.facebook.com/intern/wiki/CppCodingConventions, angle
bracket includes should go above quote includes.

Test Plan: unit tests

Reviewed By: viswanath@fb.com

Subscribers: doug, jdperlow, snaptu-diffs@, fugalh, bmatheny, nimishshah, alikhtarov, cgheorghe

FB internal diff: D1673401

Signature: t1:1673401:1415735373:b40475a4bed22fe293d094681aeccca88ad77d76
Don't throw error and use Result<> in 1 function interface

Summary: Use just one way to report errors. Just use Result.

Test Plan:
unit tests. Verified by hand that peek() doesn't
throw. out_of_range was just getting thrown from the small section of code
I wrapped in try/catch

Reviewed By: cgheorghe@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1653770

Signature: t1:1653770:1415321164:7a522255fe33ff54a5c31b32cf3636a5ba7bec79
Adding support for Ubuntu 12.04

Summary:
Adds support for building on Ubuntu 12.04 (for all folks who haven't upgraded yet)

This also fixes a minor bug in the deps.sh script, where it doesn't exit if fbthrift/folly fail to build
Closes https://github.com/facebook/proxygen/pull/15
Github Author: delow12 <dokovan@hotmail.com>

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

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

Reviewed By: cgheorghe@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1674609

Signature: t1:1674609:1415756820:a84f67d7932e7ca24c3212a8b29f7d7145addc48
Fix rare ByteEvents CHECK()

Summary:
If a ping reply is enqueued for egress and then the session is
torn down, it is possible that there is an outstanding byte event. Since
we already enforce relevant checks in HTTPSession about open transactions,
we know this isn't a leak. So, we can just clear any outstanding byte events.

Test Plan: unit tests, canary

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1676315

Tasks: 5368599

Signature: t1:1676315:1415819929:b91e02f8d7e5a035ec96dbbfe17ba2b76c7c81c6
expose some methods as virtual to make it pluggable to newer versions of the spec

Summary: no logic has changed, just some methods became virtual and with different visibility

Test Plan: unit test

Reviewed By: dcsommer@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1672319

Tasks: 5585851

Signature: t1:1672319:1415736266:cd2e5c948414983f0d58749ef3e864cf76244709
refactor StaticHeaderTable to allow plugging different header tables

Summary: move the static table outside the constructor and feed it as a parameter

Test Plan: compiled and ran the test

Reviewed By: dcsommer@fb.com, afrind@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1672322

Tasks: 5585851

Signature: t1:1672322:1415831762:ce851aabbd910229a4f8bfd612816378c0d74b64
refactor API for huffman encode/decode to allow switching tables easier

Summary: before this diff the API based on simple functions that take HPACK::MessageType as an argument and decide internally which tables to switch. This makes hard to choose a different huffman table, so now we moved all the (static) functions as methods in a HuffTree and inject that in the HPACKEncode/DecodeBuffer instead of the MessageType.

Test Plan: unit tests

Reviewed By: afrind@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1675948

Tasks: 5585851

Signature: t1:1675948:1415821650:80b3431baaa6eddcaae7846449f0b85da444d085
Revert "[proxygen] replace ThreadLocalPtr of IOBuf with a member unique_ptr in GzipHeaderCodec"

Summary: This reverts commit 0bb8ef8aeeca6c853b20221d0a47583c540d8fca. We're still seeing crashes, so we found that folly::ThreadLocal is not the culprit

Test Plan: unit tests

Reviewed By: seanc@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1681368

Tasks: 5405529

Signature: t1:1681368:1415976232:0f854000c6522030bad0aa32ab85d67ec2b00145
Add TotalConnect trace event from session managers

Summary:
Total connection time is not always dns+tcp+tls, especially when a cached
session is used. Add a TotalConnect to measure the time in both simple and adv
session managers. We will collect it in marauder.

Test Plan: unit tests modified and pass.

Reviewed By: pgriess@fb.com, fma@fb.com

Subscribers: bmatheny, seanc, kmdent, ranjeeth, subodh, benyluo

FB internal diff: D1682381

Tasks: 5607603

Signature: t1:1682381:1415998404:c9351dba19fb5125ab4ccb8af8c3edfd6a4cd420
Move Acceptor to wangle

Summary:
Initial pass at moving acceptor to wangle.  Involves moving most of the config stuff from proxygen/lib/services, and *all* of the ssl stuff from proxygen/lib/ssl.

Only minor changes:
* Acceptor can be overriden to use thrift socket types, so I don't have to change TTransportException everywhere just yet
* proxygen::Exception to std::runtime_exception in a few spots - looks like it is entirely bad config exceptions, so it should be okay
* Just used std::chrono directly instead of stuff in Time.h (which is just typedefs and simple helpers)

Test Plan:
used in D1539327

fbconfig -r proxygen/httpserver; fbmake runtests

Probably other projects are broken, will iterate to fix

None of the failling tests look related

Reviewed By: dcsommer@fb.com

Subscribers: oleksandr, netego-diffs@, hphp-diffs@, ps, trunkagent, doug, fugalh, alandau, bmatheny, njormrod, mshneer, folly-diffs@

FB internal diff: D1638358

Tasks: 5002353

Signature: t1:1638358:1414526683:87a405e3c24711078707c00b62a50b0e960bf126
Setting for conn-level recv window

Summary: We currently hardcode this to the read buf limit.  Oddly, we have a config setting for it, but it's ignored.

Test Plan: New unit test

Reviewed By: viswanath@fb.com

Subscribers: trunkagent, doug, bmatheny

FB internal diff: D1685122

Tasks: 5567513

Signature: t1:1685122:1416254396:04fbdbe4d178d132323b82d7474a91fb4c16bec5
reuse unfilled sessions

Summary:
Stacked diff on D1652916. This is one of the last pieces of session management.
D1652916 adds an interface to let SessionPool notify when a session becomes
unfilled. This diff uses that interface, onSessionAvailable(), to let
AdvancedHTTPSessionManager reuses a session just became unfilled to fulfill
waiting requests.

I had to restructure AdvancedHTTPSessionManager a bit to make things work
clearer:

1. Previously SessionInfoData is just a pure struct. All activities were
calling back to AdvHTTPSessionManager, then the session manager did a lookup to
find the corresponding SessionInfoData.

2. SessionInfoData is now the core part handling in-flight connections,
buffering waiting handles, holding a session pool, and get notifications on
unfilled sessions. All activities are calling back to SessionInfoData rather
than the session manager, avoiding an unnecesary lookup.

3. You can imagine AdvancedHTTPSessionManager now is just a container for a map
of SessionInfoData. And each SessionInfoData is a per-domain, self-contained
class that handles all the request fulfilling for that domain with advanced
session management.

4. There is one tricky thing in the implementation. Upon onSessionAvailable
called, it's not possible to process any handles with the newly unfilled
session in the same event base loop because that breaks HTTPSession. So I had
to schedule a runInEventBaseThread to process the handles. This is, however, a
potential issue when the SessionInfoData is closed before the next loop is run,
causing a dangling pointer to the SessionInfoData. The way I fixed it would
cause possible slight memory leak when the evb thread closes, but at that time
the whole app closes, so I don't think it's a big deal.

I will add more inline comments.

Test Plan:
Added a test case for reusing idle sessions. Also ran LigerPerformanceTest to
make sure nothing broken with both reusing idle sessions on and off.

Reviewed By: pgriess@fb.com

Subscribers: trunkagent, ranjeeth, bmatheny, subodh, seanc, benyluo

FB internal diff: D1657719

Tasks: 5515739

Signature: t1:1657719:1416245208:dc2d4bb9a94c38ccd20ac421b096b411f0a0cce9
hardcode HPACK NPN string

Summary: this looks silly, but we're seeing some crashes in Liger when we construct the static string using folly/Conv.h;

Test Plan: unit tests and ran HPACK with proxygen local build and FBIOS on my phone

Reviewed By: seanc@fb.com

Subscribers: trunkagent, doug, bmatheny, cgheorghe

FB internal diff: D1686654

Tasks: 5590408

Signature: t1:1686654:1416274964:f9e1820db5b628f1daa79d92ac36d4e8e76b3dcb
minor: replace protocol version constants with an explanatory comment

Summary: the constants were not used anymore and were just serving as a comment. Also linked the spec version from the comments

Test Plan: compiled

Reviewed By: seanc@fb.com

Subscribers: doug, bmatheny, cgheorghe

FB internal diff: D1687810

Signature: t1:1687810:1416327250:2f9ccdd25f76327a0ea2b227f836aa6ef39321d6
Tests for cleaning up push txn on failures

Summary: See https://phabricator.fb.com/D1686512#inline-12631891

Test Plan: fbmake runtests

Reviewed By: dcsommer@fb.com

Subscribers: bmatheny

FB internal diff: D1688417

Signature: t1:1688417:1416340997:e9e7b71f7abc124fe814a7b789bc3eb412035fa2
Set default action for HTTP/2+ style tests

Summary:
`generateRstStream()` should return > 0 values for SPDY or
HTTP/2+ tests. HTTPSession depends on this return value to determine if
the protocol was able to cancel the stream without needing to tear down
the whole connection (as you need to do for HTTP/<=1.1).

I also deleted some redundant code.

Test Plan: unit tests, needed for upcoming diff

Reviewed By: afrind@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1688898

Signature: t1:1688898:1416354897:2915d23bfabe0f10e4510bd7eabaf1c4e41be966
add happy eyeballs trace event

Summary:
Add trace events on happy eyeballs for liger.
For now we collect only if ipv4 / ipv6 success for this request and the
total time for connect, in the future we can add more metric into the data.

Test Plan:
unit test:
fbconfig -r proxygen/facebook/httpclient/ && fbmake runtests test:RequestStatsTest
fbconfig -r proxygen/facebook/lib/transport/ && fbmake runtests test:transport_test

will manually sync to device and get happy eyeballs info in my domino.

Reviewed By: seanc@fb.com

Subscribers: trunkagent, minyoung, ranjeeth, seanc, fma, shikong, pgriess, kmdent, subodh, bmatheny

FB internal diff: D1685810

Tasks: 4047940

Signature: t1:1685810:1416334888:3bbc018eac5c8c58e1e7d3f3c1f8317d7b10c074
Dockerizing

Summary:
Add docker support for convenience development environment.
Closes https://github.com/facebook/proxygen/pull/18
Github Author: rezacute <rezaqt@gmail.com>

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

Test Plan: community feedback

Reviewed By: praveenr@fb.com

Subscribers: doug, bmatheny

FB internal diff: D1673140

Signature: t1:1673140:1415753811:e9785250c236a794773287244c8dbea558314cb4