README.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. = POST parameter echo 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. As this example echoes a POST parameter, it is a little more
  7. complex to test. Some browsers feature tools that allow you
  8. to perform one such request, or you can use the command line
  9. tool `curl` as we will demonstrate.
  10. == HTTP/1.1 example output
  11. [source,bash]
  12. ----
  13. $ curl -i -d echo=echomeplz http://localhost:8080
  14. HTTP/1.1 200 OK
  15. connection: keep-alive
  16. server: Cowboy
  17. date: Fri, 28 Sep 2012 04:12:36 GMT
  18. content-length: 9
  19. content-type: text/plain; charset=utf-8
  20. echomeplz
  21. ----
  22. == HTTP/2 example output
  23. [source,bash]
  24. ----
  25. $ echo echo=echomeplz | nghttp -v -d - http://localhost:8080
  26. [ 0.000] Connected
  27. [ 0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
  28. (niv=2)
  29. [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
  30. [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
  31. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
  32. (dep_stream_id=0, weight=201, exclusive=0)
  33. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
  34. (dep_stream_id=0, weight=101, exclusive=0)
  35. [ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
  36. (dep_stream_id=0, weight=1, exclusive=0)
  37. [ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
  38. (dep_stream_id=7, weight=1, exclusive=0)
  39. [ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
  40. (dep_stream_id=3, weight=1, exclusive=0)
  41. [ 0.001] send HEADERS frame <length=43, flags=0x24, stream_id=13>
  42. ; END_HEADERS | PRIORITY
  43. (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
  44. ; Open new stream
  45. :method: POST
  46. :path: /
  47. :scheme: http
  48. :authority: localhost:8080
  49. accept: */*
  50. accept-encoding: gzip, deflate
  51. user-agent: nghttp2/1.7.1
  52. content-length: 15
  53. [ 0.001] send DATA frame <length=15, flags=0x00, stream_id=13>
  54. [ 0.001] send DATA frame <length=0, flags=0x01, stream_id=13>
  55. ; END_STREAM
  56. [ 0.012] recv SETTINGS frame <length=0, flags=0x00, stream_id=0>
  57. (niv=0)
  58. [ 0.012] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
  59. ; ACK
  60. (niv=0)
  61. [ 0.012] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
  62. ; ACK
  63. (niv=0)
  64. [ 0.020] recv (stream_id=13) :status: 200
  65. [ 0.020] recv (stream_id=13) content-length: 10
  66. [ 0.020] recv (stream_id=13) content-type: text/plain; charset=utf-8
  67. [ 0.020] recv (stream_id=13) date: Thu, 09 Jun 2016 09:19:35 GMT
  68. [ 0.020] recv (stream_id=13) server: Cowboy
  69. [ 0.020] recv HEADERS frame <length=57, flags=0x04, stream_id=13>
  70. ; END_HEADERS
  71. (padlen=0)
  72. ; First response header
  73. echomeplz
  74. [ 0.020] recv DATA frame <length=10, flags=0x01, stream_id=13>
  75. ; END_STREAM
  76. [ 0.020] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
  77. (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
  78. ----