{"id":250,"date":"2010-01-21T01:03:34","date_gmt":"2010-01-21T09:03:34","guid":{"rendered":"http:\/\/www.onvural.net\/melih\/thoughts\/?p=250"},"modified":"2010-01-21T01:03:34","modified_gmt":"2010-01-21T09:03:34","slug":"being-restful-aint-that-easy","status":"publish","type":"post","link":"https:\/\/www.onvural.net\/melih\/thoughts\/2010\/01\/21\/being-restful-aint-that-easy\/","title":{"rendered":"Being RESTful ain&#8217;t that easy"},"content":{"rendered":"<p>This is a more technical post, and so if you aren&#8217;t interested in some nuances of browsers and Internet architecture, then you should pass on this one. It&#8217;s okay, you won&#8217;t hurt my feelings.<\/p>\n<p>Man, we ran into a doozy today. We had one report from a user that people weren&#8217;t able to enter their moderated video chats. We weren&#8217;t sure that made any sense, and we couldn&#8217;t find any records of failure to enter the video chat in our error logs. It turns out we made two mistakes. First, we didn&#8217;t gather enough information. Second, we didn&#8217;t understand the errors we were getting back. Both, thankfully, are now fixed, but the journey was an interesting one.<\/p>\n<p>First, let me give a little bit of background on our new architecture. We&#8217;ve just released our new call moderation stack at <a href=\"http:\/\/www.tokbox.com\">TokBox<\/a>, and, to do so, we really sat down and thought through how to build this functionality in an Internet architecture appropriate approach. We came up with a really solid, <a id=\"aptureLink_zVtNILRMJm\" href=\"http:\/\/en.wikipedia.org\/wiki\/Representational%20State%20Transfer\">RESTful<\/a> API. The basic premise here is that all actions have a URI, and are a very specific contract between two endpoints (one being the user making the call, the second being our server). It was all very well tested on a Mac in both FireFox and Safari.<\/p>\n<p>Here&#8217;s where the real journey begins. In RESTful fashion, we are defining the user&#8217;s role in a moderated chat by transitioning them from an &#8220;ASK&#8221; state where they are essentially knocking to get in, into a &#8220;PARTICIPANT&#8221; state where they have joined the call. The modify action uses the POST verb (though technically it should use the PUT verb, we weren&#8217;t confident in the Flex framework&#8217;s HTTPService class to handle this properly, and have instead limited ourselves to POST and GET), and then redirects to the user info action which returns the updated role, as well as any profile information about the user that might be pertinent to the video chat. <\/p>\n<p>Now here is the gotcha. We use an HTTP 302 redirect to move between the actions. In all browsers not IE, it looks as if the 302 happens by first doing the verb of your choosing (in our case a POST), and then a GET to the redirected site. According to the spec as we read it, this is probably wrong. In fact, the redirect needs to ask the browser which verb to use in the HTTP\/1.1 spec. Seems as if the HTTP\/1.1 spec is either being misinterpreted, or the HTTP\/1.0 spec is being maintained to enable backwards compatibility with how sites acted. Why did this cause us a problem? Because in IE7 &amp; IE8, the 302 redirect does a POST (essentially repeats the original verb action). Our user info action was scoped as only accepting GET requests. The result&#8230; guest users couldn&#8217;t enter a moderated video chat from the IE family of browsers because the redirect fell into an error state, and didn&#8217;t return the proper response.<\/p>\n<p>It took watching the TCPDump coming across the server across multiple browsers and API calls to figure this one out, but in the end we learned a very valuable lesson about how redirects work, making RESTful APIs work cross browser, and making sure we test across all combination of browsers and scenarios.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a more technical post, and so if you aren&#8217;t interested in some nuances of browsers and Internet architecture, then you should pass on this one. It&#8217;s okay, you won&#8217;t hurt my feelings. Man, we ran into a doozy today. We had one report from a user that people weren&#8217;t able to enter their [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[2,1],"tags":[25,26,27,28],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pQyAq-42","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1705,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2016\/05\/03\/im-leaving-tokbox\/","url_meta":{"origin":250,"position":0},"title":"I'm leaving TokBox","date":"May 3, 2016","format":false,"excerpt":"Friday will be my last day at TokBox. It ends an eight year journey through multiple products, lots of different target audiences, four CEOs, and three different careers. I asked Scott if I could say a few words at my last team meeting. I didn't make it to the first\u2026","rel":"","context":"In &quot;Life Updates&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1348,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2014\/11\/17\/3-days-til-30\/","url_meta":{"origin":250,"position":1},"title":"3 days til 30","date":"November 17, 2014","format":false,"excerpt":"Well, I've run out of ideas, and steam. So today's post will be a photo gallery of the last 10 years. Thanks for keeping up with me :-) (Post-looking up all of the photos... holy shit what a great decade)","rel":"","context":"In &quot;just thinking out loud&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":297,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2010\/02\/26\/building-a-community\/","url_meta":{"origin":250,"position":2},"title":"Building a community","date":"February 26, 2010","format":false,"excerpt":"I was talking to someone today about the TokBox Platform that we're building. It's been something that I've been working on since I joined the Box, and something about which I'm very passionate. I was discussing with them my three goals for the Platform from a developer point of view\u2026","rel":"","context":"In &quot;just thinking out loud&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":176,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2009\/09\/16\/college-football-week-3\/","url_meta":{"origin":250,"position":3},"title":"College Football - Week 3","date":"September 16, 2009","format":false,"excerpt":"Join the weekly picks group at: Link: http:\/\/football.fantasysports.yahoo.com\/college Group #: 28253 Password: Call me on TokBox to find out at http:\/\/www.tokbox.com\/melih","rel":"","context":"In &quot;Sports betting&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":483,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2011\/11\/17\/its-not-okay-to-say-nothing\/","url_meta":{"origin":250,"position":4},"title":"It's not okay to say nothing","date":"November 17, 2011","format":false,"excerpt":"I found out today how important it is to be vocal when you really believe in something. First some background: I believe that the reason that TokBox is successful right now is because we've built the right culture. Hiring in the Valley is a bitch, and if you aren't careful,\u2026","rel":"","context":"In &quot;Becoming a PM&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":882,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2014\/02\/06\/a-months-worth-of-small-steps\/","url_meta":{"origin":250,"position":5},"title":"A month's worth of small steps","date":"February 6, 2014","format":false,"excerpt":"We had a really great demo day today. It's the beginning of celebrating lots of small steps. At the end of the road, I think we'll all find it was a journey worth taking. And through it, we'll have lots of stories to tell :-) The tradition of celebrating small\u2026","rel":"","context":"In &quot;Becoming a PM&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/posts\/250"}],"collection":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":0,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}