README.asciidoc 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. = Secure hello world example
  2. To try this example, you need GNU `make` and `git` in your PATH.
  3. To build and run the example, use the following command:
  4. [source,bash]
  5. $ make run
  6. Then point your browser to https://localhost:8443
  7. You will need to temporarily trust the root certificate authority,
  8. which can also be found in `priv/ssl/cowboy-ca.crt`.
  9. Recent browsers will communicate using HTTP/2. Older browsers
  10. will use HTTP/1.1.
  11. == HTTP/1.1 example output
  12. [source,bash]
  13. ----
  14. $ curl --cacert priv/ssl/cowboy-ca.crt -i https://localhost:8443
  15. HTTP/1.1 200 OK
  16. connection: keep-alive
  17. server: Cowboy
  18. date: Fri, 28 Sep 2012 04:10:25 GMT
  19. content-length: 12
  20. Hello world!
  21. ----
  22. == HTTP/2 example output
  23. [source,bash]
  24. ----
  25. $ nghttp -v https://localhost:8443
  26. [ 0.001] Connected
  27. The negotiated protocol: h2
  28. [ 0.009] recv SETTINGS frame <length=0, flags=0x00, stream_id=0>
  29. (niv=0)
  30. [ 0.009] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
  31. (niv=2)
  32. [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
  33. [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
  34. [ 0.009] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
  35. ; ACK
  36. (niv=0)
  37. [ 0.009] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
  38. (dep_stream_id=0, weight=201, exclusive=0)
  39. [ 0.009] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
  40. (dep_stream_id=0, weight=101, exclusive=0)
  41. [ 0.009] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
  42. (dep_stream_id=0, weight=1, exclusive=0)
  43. [ 0.009] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
  44. (dep_stream_id=7, weight=1, exclusive=0)
  45. [ 0.009] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
  46. (dep_stream_id=3, weight=1, exclusive=0)
  47. [ 0.009] send HEADERS frame <length=38, flags=0x25, stream_id=13>
  48. ; END_STREAM | END_HEADERS | PRIORITY
  49. (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
  50. ; Open new stream
  51. :method: GET
  52. :path: /
  53. :scheme: https
  54. :authority: localhost:8443
  55. accept: */*
  56. accept-encoding: gzip, deflate
  57. user-agent: nghttp2/1.7.1
  58. [ 0.010] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
  59. ; ACK
  60. (niv=0)
  61. [ 0.010] recv (stream_id=13) :status: 200
  62. [ 0.010] recv (stream_id=13) content-length: 12
  63. [ 0.010] recv (stream_id=13) content-type: text/plain
  64. [ 0.010] recv (stream_id=13) date: Sat, 30 Apr 2016 12:54:32 GMT
  65. [ 0.010] recv (stream_id=13) server: Cowboy
  66. [ 0.010] recv HEADERS frame <length=45, flags=0x04, stream_id=13>
  67. ; END_HEADERS
  68. (padlen=0)
  69. ; First response header
  70. Hello world![ 0.010] recv DATA frame <length=12, flags=0x01, stream_id=13>
  71. ; END_STREAM
  72. [ 0.010] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
  73. (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
  74. ----