Cory Kendall
Cory Kendall

Reputation: 7304

Should a webserver ignore extra query params or return an error?

I'm implementing the logic for a RESTful web server which supports searching with a SolR like syntax. Here are some common valid requests:

My question is very generic; what should I do if I receive a request like this?

I received a query parameter "something" which has no meaning to me, and our search engine will ignore it. Should I

Upvotes: 1

Views: 1045

Answers (2)

Lee Meador
Lee Meador

Reputation: 12985

Many web pages just ignore stuff that they aren't expecting.

Usually the URL and parameters are a result of clicking something or running some code on a browser or web service client. These would seldom submit anything unexpected.

If there is some reason you expect someone to be fooling with your web site and submitting requests that are "hackish" in some fashion, you might want to lock them out by recognizing illegal parameters and returning some error. 4xx would be reasonable for REST service.

Upvotes: 1

Leeish
Leeish

Reputation: 5213

Read the HTTP status definitions. I would practice not returning anything with bad info. The definition of 400 is The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. and seems appropriate here, but your use case may deem otherwise.

If you IGNORE you are not giving the client any information. They may never know something is wrong.

Upvotes: 0

Related Questions