Adding JSONP to Nginx Upload Progress Module

18Dec07

Today I successfully (with a bit of help from friends) managed to add JSONP support to the Nginx upload progress module C code. I’m dead chuffed since: 1) this is the first time I have ever managed to modify a C program to do what I want, 2) the Nginx code is ninja. What the hell is JSONP ??? Good question. Its a way to get around the restriction that AJAX calls can only be sent to the same domain as that of the page. You embed a dynamic script element in the page and point it at the server which returns JSONP. Its just like usual JSON but wrapped in parenthesis and prefixed with the value of the ‘jsonp’ parameter passed with the get request. This turns plain JSON data into JSON data wrapped in a callback function call. An example is probably in order..

JSON:

GET /foo
{hello:’world’}

JSONP:

GET /foo?jsonp=callback_1
callback_1({hello:’world’})

Once I have tested the code a bit more I will send a patch to the original module author. But if you are feeling daring you can download the hacked module here.

Advertisements


No Responses Yet to “Adding JSONP to Nginx Upload Progress Module”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: