Robustness Principle

Recently, while working on an iOS app I was writing client code that requests a web service.
It was a GET request.
According to the service documentation, the request accepted some parameters.
But when adding these parameters to the request did not yield expected response, I requested the API developer to shed some light.
The developer provided me with a cURL representation of the request and I found that parameters were passed in the –data option of the request.
While this is allowed, it is not the recommended approach – passing data in the body of the GET request.

This answer on stack overflow quotes from the RFC2616 – Hypertext Transfer Protocol — HTTP/1.1 and describes that the approach is not forbidden. So it’s allowed to send entity-body with a HTTP GET request.
Whereas this answer describes that the GET body has no semantic meaning.
Also, this post suggests avoiding it simply because it’s not expected. It also talks about the Robustness Principle that wikipedia summarizes as Be conservative in what you do, be liberal in what you accept from others.

In our client-server scenario, this translates to following:
The client should request the server in a way that is concise and conforms to the specifications but the server should be open to any kind of request as long as it is semantically correct.

Coming back to our iOS client side code, I found out from an answer on google groups that while this was possible through the cURL representation from the terminal, iOS would not allow it.

Finally, I had to ask the API developer to make some changes and the request was changed to POST.

Advertisements
By akshay1188