cs3org / wopiserver

A vendor-neutral application gateway compatible with the WOPI specifications.
Apache License 2.0
52 stars 27 forks source link

Make sure all responses are in JSON format #96

Closed glpatcern closed 1 year ago

glpatcern commented 1 year ago

Currently in case of errors we return a raw text string most of the time in the HTTP Body, along with the HTTP status code (which is what matters for the WOPI apps). JSON is used only in some specific cases, e.g. PutRelative.

It would be good to ensure JSON is used all over the places, and in addition some standard response headers could be added from https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/common-headers#response-headers

osamaahmed17 commented 1 year ago

@glpatcern, I am interested in this task and would start looking at it. It would be great if you could answer the following queries: 1 - Do you want this change to be in every file? 2 - Can you provide me with an example area in the code where this change is needed?

glpatcern commented 1 year ago

@osamaahmed17 feel free, just consider that this year we are not hosting any GSoC student.

osamaahmed17 commented 1 year ago

@glpatcern, I know about that. I have more time nowadays to work open source. Plus, it would be great that if you can answer my above queries so I can work upon it.

glpatcern commented 1 year ago

1 - Do you want this change to be in every file?

More than in every file, this concerns every server response, therefore the most affected source file is src/core/wopi.py.

2 - Can you provide me with an example area in the code where this change is needed?

A typical case is https://github.com/cs3org/wopiserver/blob/master/src/core/wopi.py#L496, where a better response would be some "standard" JSON like {"message" : "<the error message>"} along with the http error code.