README.asciidoc 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. = File server example with directory listing
  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 http://localhost:8080
  7. to browse the contents of the `priv` directory.
  8. Interesting examples include:
  9. * http://localhost:8080/test.txt[Plain text file]
  10. * http://localhost:8080/video.html[HTML5 video demo]
  11. == HTTP/1.1 example output
  12. [source,bash]
  13. ----
  14. $ curl -i http://localhost:8080/test.txt
  15. HTTP/1.1 200 OK
  16. connection: keep-alive
  17. server: Cowboy
  18. date: Mon, 09 Sep 2013 13:49:50 GMT
  19. content-length: 52
  20. content-type: text/plain
  21. last-modified: Fri, 18 Jan 2013 16:33:31 GMT
  22. If you read this then the static file server works!
  23. ----
  24. == HTTP/2 example output
  25. [source,bash]
  26. ----
  27. $ nghttp -v http://localhost:8080/test.txt
  28. [ 0.000] Connected
  29. [ 0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
  30. (niv=2)
  31. [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
  32. [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
  33. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
  34. (dep_stream_id=0, weight=201, exclusive=0)
  35. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
  36. (dep_stream_id=0, weight=101, exclusive=0)
  37. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
  38. (dep_stream_id=0, weight=1, exclusive=0)
  39. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
  40. (dep_stream_id=7, weight=1, exclusive=0)
  41. [ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
  42. (dep_stream_id=3, weight=1, exclusive=0)
  43. [ 0.000] send HEADERS frame <length=46, flags=0x25, stream_id=13>
  44. ; END_STREAM | END_HEADERS | PRIORITY
  45. (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
  46. ; Open new stream
  47. :method: GET
  48. :path: /test.txt
  49. :scheme: http
  50. :authority: localhost:8080
  51. accept: */*
  52. accept-encoding: gzip, deflate
  53. user-agent: nghttp2/1.7.1
  54. [ 0.001] recv SETTINGS frame <length=0, flags=0x00, stream_id=0>
  55. (niv=0)
  56. [ 0.001] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
  57. ; ACK
  58. (niv=0)
  59. [ 0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
  60. ; ACK
  61. (niv=0)
  62. [ 0.007] recv (stream_id=13) :status: 200
  63. [ 0.007] recv (stream_id=13) content-length: 52
  64. [ 0.007] recv (stream_id=13) content-type: text/plain
  65. [ 0.007] recv (stream_id=13) date: Mon, 13 Jun 2016 11:25:20 GMT
  66. [ 0.007] recv (stream_id=13) etag: "1371478245"
  67. [ 0.007] recv (stream_id=13) last-modified: Tue, 12 Aug 2014 17:00:17 GMT
  68. [ 0.007] recv (stream_id=13) server: Cowboy
  69. [ 0.007] recv HEADERS frame <length=81, flags=0x04, stream_id=13>
  70. ; END_HEADERS
  71. (padlen=0)
  72. ; First response header
  73. If you read this then the static file server works!
  74. [ 0.007] recv DATA frame <length=52, flags=0x01, stream_id=13>
  75. ; END_STREAM
  76. [ 0.007] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
  77. (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
  78. ----