periscope-ps / periscope

perfSONAR Infrastructure for Synthesis and Charting of Online Performance Events
11 stars 1 forks source link

RESTful UNIS accepted content-type #7

Open disprosium8 opened 12 years ago

disprosium8 commented 12 years ago

Is there a reason we need application/perfsonar+json instead of just application/json ? Could the service accept both? What are the implications?

dangunter commented 12 years ago

I think the service should look at the media types that the client can accept, and respond with JSON to any of application/json, text/javascript, or even text/plain. If only text/html is accepted it's time to either return some formatted info. or an error.

However, this doesn't rule out smarter clients doing something fancier like:

application/vnd.perfsonar+json;version=0.1.3

-Dan

On Fri, Aug 3, 2012 at 6:36 AM, Ezra Kissel < reply@reply.github.com

wrote:

Is there a reason we need application/perfsonar+json instead of just application/json ? Could the service accept both? What are the implications?


Reply to this email directly or view it on GitHub: https://github.com/periscope-ps/periscope/issues/7

disprosium8 commented 12 years ago

You raise a good point about the responses the service generates. Thus far I haven't run into any issues on that front, using libcurl in C anyway.

My initial concern was about the service accepting POST/PUT requests as application/json, e.g.:

$ curl -X POST -H "Content-Type: application/json" -d @xspd_service_newy.json http://dev.incntre.iu.edu/services Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/tornado-2.3-py2.6.egg/tornado/web.py", line 1000, in _stack_context_handle_exception raise_exc_info((type, value, traceback)) File "/usr/local/lib/python2.6/dist-packages/tornado-2.3-py2.6.egg/tornado/web.py", line 1118, in wrapper return method(self, _args, _kwargs) File "/usr/local/lib/python2.6/dist-packages/tornado-2.3-py2.6.egg/tornado/web.py", line 1141, in wrapper return method(self, _args, _kwargs) File "/home/ahassany/GEMINI/contrib/periscope/peri-tornado/periscope/handlers.py", line 742, in post if self.content_type == MIME['PSJSON']: File "/home/ahassany/GEMINI/contrib/periscope/peri-tornado/periscope/handlers.py", line 371, in content_type self.request.headers.get("Content-Type", "")) HTTPError: HTTP 415: Unsupported content type 'application/json'

Switching to -H "Content-Type: application/perfsonar+json" works fine. It just seems to me that if the request is in valid json, then the service should also accept application/json too, or am I off base?

dangunter commented 12 years ago

Yes I agree, sorry I answered the wrong question there. btw, application/perfsonar+json is a kind of bogus MIME type in my opinion, since that's a space IANA controls and it's not listedhttp://www.iana.org/assignments/media-types/application/ , unlike application/json. That's why I suggested the "vendor" namespace which is supposed to be extended.

-Dan

On Fri, Aug 3, 2012 at 12:53 PM, Ezra Kissel < reply@reply.github.com

wrote:

You raise a good point about the responses the service generates. Thus far I haven't run into any issues on that front, using libcurl in C anyway.

My initial concern was about the service accepting POST/PUT requests as application/json, e.g.:

$ curl -X POST -H "Content-Type: application/json" -d @xspd_service_newy.json http://dev.incntre.iu.edu/services Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/tornado-2.3-py2.6.egg/tornado/web.py", line 1000, in _stack_context_handle_exception raise_exc_info((type, value, traceback)) File "/usr/local/lib/python2.6/dist-packages/tornado-2.3-py2.6.egg/tornado/web.py", line 1118, in wrapper return method(self, _args, _kwargs) File "/usr/local/lib/python2.6/dist-packages/tornado-2.3-py2.6.egg/tornado/web.py", line 1141, in wrapper return method(self, _args, _kwargs) File "/home/ahassany/GEMINI/contrib/periscope/peri-tornado/periscope/handlers.py", line 742, in post if self.content_type == MIME['PSJSON']: File "/home/ahassany/GEMINI/contrib/periscope/peri-tornado/periscope/handlers.py", line 371, in content_type self.request.headers.get("Content-Type", "")) HTTPError: HTTP 415: Unsupported content type 'application/json'

Switching to -H "Content-Type: application/perfsonar+json" works fine. It just seems to me that if the request is in valid json, then the service should also accept application/json too, or am I off base?


Reply to this email directly or view it on GitHub: https://github.com/periscope-ps/periscope/issues/7#issuecomment-7492722