[Data pipelining] Patch: HttpRequest format and error handling

2 views
Skip to first unread message

Adam Winer

unread,
Mar 31, 2009, 5:13:12 PM3/31/09
to ♫
This patch addresses the two remaining issues I'm aware of with the
data pipelining spec, defining the format for os:HttpRequest and
defining how errors are processed

http://codereview.appspot.com/32088/diff/1/2

Complete details in the patch, but for inline ease, here's the
os:HttpRequest response format:

// @format='text' example
{data: {
content: 'Hi there!',
status: 200,
headers: {'Content-Type': ['text/plain;charset=utf-8']}
}}

// @format='json' example
{data: {
content: {'hi': 'there!'},
status: 200,
headers: {'Content-Type': ['application/json;charset=utf-8']}
}}

// 404 error
{error: {
code: 404,
message: 'Resource not found'
}}

// Unparseable JSON
{error: {
code: 406
}}

... and here's how error handling deals with network-level errors for
Javascript:

<script xmlns:os="http://ns.opensocial.org/2008/markup"
type="text/os-data">
<os:ViewerRequest key="vwr"/>
<os:PeopleRequest key="vf" userId="@viewer" groupId="@friends"/>
</script>

If the above request failed with a server error, the resulting
dataset would contain content resembling:
{vwr: {error: {message: 'Server error', code: 500}}, vf: {error:
{message: 'Server error', code: 500}}}

-- Adam

Scott Seely

unread,
Mar 31, 2009, 6:00:29 PM3/31/09
to opensocial-an...@googlegroups.com
+1

Lev Epshteyn

unread,
Mar 31, 2009, 6:10:29 PM3/31/09
to opensocial-an...@googlegroups.com
+1

Louis Ryan

unread,
Apr 1, 2009, 12:46:54 AM4/1/09
to opensocial-an...@googlegroups.com
Largely +1, one comment about error responses 

Louis Ryan

unread,
Apr 1, 2009, 12:49:10 AM4/1/09
to opensocial-an...@googlegroups.com
Inlining for convenience

Should clarify some things about errors. message should be a description of the HTTP status code mapped into error and not the body of the HTTP error response. Use an additional 'data' field to include headers, and actual response message body which can have type just as non-error responses do . E.g. {error : { code : 404, message : 'Resource not found', data : { content : "...<escaped html>...", headers: {'Content-Type': ["text/html"]} }

Use of 'data' aligns with JSON-RPC 2. Having the headers can be useful when requests are rejected for auth reasons or simulating cookie management.

Chris Chabot

unread,
Apr 1, 2009, 10:13:32 AM4/1/09
to opensocial-an...@googlegroups.com
+1, nice to have this defined and cleared up!

Adam Winer

unread,
Apr 1, 2009, 11:27:52 AM4/1/09
to opensocial-an...@googlegroups.com
Thanks - I've updated the patch with corresponding text.  Feedback in particular welcome on MUST/SHOULD/MAY for the following block:

   For errors, the "message" property MUST NOT contain the response body, but
   SHOULD contain a descriptive message describing the HTTP error.
   The error MAY contain a data block providing the content and headers.

(and examples of the syntax follow).

Scott Seely

unread,
Apr 1, 2009, 12:15:36 PM4/1/09
to opensocial-an...@googlegroups.com

Still ok with thisJ

+1

 

Arne—if there are no objections by EOD, please commit this edit Thursday AM. http://codereview.appspot.com/32088/

Louis Ryan

unread,
Apr 1, 2009, 12:17:43 PM4/1/09
to opensocial-an...@googlegroups.com
+1

Evan Gilbert

unread,
Apr 1, 2009, 1:35:23 PM4/1/09
to opensocial-an...@googlegroups.com
+1

Arne Roomann-Kurrik

unread,
Apr 2, 2009, 3:52:06 PM4/2/09
to opensocial-an...@googlegroups.com
Committed at http://code.google.com/p/opensocial-resources/source/detail?r=1078

~Arne

On Wed, Apr 1, 2009 at 9:15 AM, Scott Seely <sSe...@myspace.com> wrote:



--
OpenSocial IRC - irc://irc.freenode.net/opensocial
Reply all
Reply to author
Forward
0 new messages