knuton / stubb

Specify REST API stubs using your file system.
MIT License
288 stars 10 forks source link

works from curl but not from browser #13

Open devel-pa opened 11 years ago

devel-pa commented 11 years ago

Hi, Cool stuff. My env: Win7 x64 Ruby 1.9.3 Stubb 0.1.3

curl http://localhost:4040/hello-world

::1 - - [23/Jul/2013 17:21:17] "GET /hello-world HTTP/1.1" 200 6 0.0080 "D:/project/services/hello-world.GET" "YAML Frontmatter: No" DEV64.AD.LAN.NET - - [23/Jul/2013:17:21:17 Paris, Madrid (heure d??t?)] "GET /hello-world HTTP/1.1" 200 6

from browser

::1 - - [23/Jul/2013 17:21:25] "GET /hello-world HTTP/1.1" 404 - 0.0070 "NONE" "YAML Frontmatter: No" DEV64.AD.LAN.NET - - [23/Jul/2013:17:21:25 Paris, Madrid (heure d??t?)] "GET /hello-world HTTP/1.1" 404 10

PS: Works from the Poster Chrome extension

knuton commented 11 years ago

The reason it doesn't work from your browser is probably that it sends an accept header something like:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Whereas curl (and presumably the Chrome extension) asks for:

Accept: */*

Stubb does not currently possess any proper content negotiation capabilities which would be necessary to accommodate the browser request, attempting to find one of the first three options, before settling for anything (*/*). Stubb simply looks for the first option, so for the browser request it looks for a file ending in .html.

I would be interested in seeing Stubb completed in this respect.