5 ms·
HTTP responses as a service
- claudius 13y agoMust have been fun to implement 418 =) It could help to link to some explanation/section in the RFC from the front page error code. Apart from that, this is very nice and potentially useful, thank you very much.
- stevekemp 13y agoThe last time I used something like this it was http://httpstat.us/ http://httpstat.us/
- patjoh 13y agoI'm been using http://httpbin.org/ http://httpbin.org/ for this.
- izuzak 13y agoYep. Also: http://www.mocky.io/ http://www.mocky.io/, http://ivanzuzak.info/urlecho/ http://ivanzuzak.info/urlecho/, and in some cases: http://hang.nodester.com/ http://hang.nodester.com/
- diminoten 13y agoOh my goodness, I've been looking for this (mocky) for weeks! Thank you. There really isn't much by way of this particular service, and I found it immensely valuable when I used it last.
- guan 13y agoWhat happens when you request a non-existent URL at that site?
- samuelh 13y ago$ curl -i http://mock.isssues.com/888 http://mock.isssues.com/888 HTTP/1.1 404 Not Found Content-Type: text/html;charset=utf-8 Date: Sun, 21 Jul 2013 22:29:14 GMT Status: 404 Not Found X-Frame-Options: sameorigin X-Xss-Protection: 1; mode=block Content-Length: 9 Connection: keep-alive
- samuelh 13y ago$ curl -i http://mock.isssues.com/fake/url http://mock.isssues.com/fake/url curl: (6) Could not resolve host: mohttp; nodename nor servname provided, or not known
- nwh 13y agoNo 451 response? https://tools.ietf.org/html/draft-tbray-http-legally-restricted-status-00 https://tools.ietf.org/html/draft-tbray-http-legally-restric...
- cbsmith 13y agoYup, sent the author a note on that.
- munimkazia 13y agoWhat about the redirect responses in the 3xx series?
- adsche 13y agoAre you the creator? FYI, http://mock.isssues.com/timeout http://mock.isssues.com/timeout gives me an application error instead of returning successfully after 30s. Result of curl -i http://mock.isssues.com/timeout here: http://pastebin.com/nM1VTYwg http://pastebin.com/nM1VTYwg
- dlitz 13y agoHow do you know that you've implemented 402 correctly?
- philjackson 13y agoI have a confession to make. I just spent three minutes trying to work out why http://mock.isssues.com/400 http://mock.isssues.com/400 was returning bad request behind ApiAxle...
- ville 13y agoNice! For completeness' sake, also 3xx redirects could be implemented, redirecting to http://mock.isssues.com/200 http://mock.isssues.com/200 for example.
- yesimahuman 13y agoLast year I was the maintainer for jQuery-Mockjax (https://github.com/appendto/jquery-mockjax https://github.com/appendto/jquery-mockjax) which essentially mocks jQuery's ajax calls. Makes it really easy to test these kinds of conditions on the client without needing to set up a server. IIRC it also supports simulated response delays. You'll never know the difference!
- spellboots 13y agoYou should almost always, for almost every test suite, do this with a mocking library. That being said, I can think of some cases where this service would be really useful, such as one of tests on live systems for example.
- grandalf 13y agothis looks like a useful service... with one caveat in the form of a rant: I wish people would stop trying to make response codes into more than they are. Rest does not entail webdav, and without webdav there are not enough semantics to try to do the kinds of things people typically try to make response codes do. If you are implementing webdav, call it that and stick to the spec, don't just hack a middle ground and pretend you are designing the API properly.
- emperorcezar 13y agoSadly the http codes were never designed for API calls in the first place, but are the recommended, and accepted way of expressing errors in APIs. The choice is to use woefully vague codes, or move out into other standards such as Webdav. Or of course custom codes.
- grandalf 13y agoI've found that many APIs sloppily use parts of webdav and create a fairly ugly hybrid approach. I think the HTTP codes should be used simply to reflect the transport (in this case HTTP) and any application level stuff should be returned in a systematic way inside the response body. Which means any API call to a valid resource that the user has access to should return a 200. Then clients can safely assume that if they get a 4xx or 5xx something is breaking, and if it's a 200 then look at the body and deal with the actual response.
- masklinn 13y agoObviously you can add a more detailed payload in the response body for precision, HTTP status codes are the error class (similar to SQL error code classes, or even the error codes themselves for such things as the class 23 codes)
- skrebbel 13y agoCould you elaborate? My limited experience with WebDAV is what Subversion uses it for, and I've always had the impression that the PROPFIND-type of verbs could just as well be expressed as GET operations on a "property" resource type. I've dismissed WebDAV as "not getting the point" since, but your comment gives me the feeling that that might've been too quick a conclusion. What's the good parts of WebDAV and how do they help me make decent RESTful APIs?
- jwcrux 13y agoRequest: http://mock.isssues.com/{RESPONSE}/{MESSAGE} http://mock.isssues.com/{RESPONSE}/{MESSAGE}
- deleted 13y ago[deleted]
- AndrewVos 13y agoanmo does all that, and more: https://github.com/sthulbourn/anmo https://github.com/sthulbourn/anmo
- waxjar 13y agoI'd rather mock stuff like this with a mocking library that doesn't involve making requests to remote servers. The interwebs are (relatively) slow and I want my tests to run fast.
- ams6110 13y agoSometimes you just want to do a quick test and not deal with the complexity of a proper mocking library. But I agree this is not something you'd probably want to bake into a continuous integration build.