Mercurial > p > roundup > code
comparison roundup/rest.py @ 5984:25a813415d59
issue2551069 - when unsupported type is found report type
When reporting an unsupported response type, error 406, report what
type is seen by the code. Allows the user to better debug the
query. E.G. look at the url and see if they mistyped it (e.g. by
leaving a ? out of the url), or a mispelled accept header value or
....
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 26 Nov 2019 09:55:09 -0500 |
| parents | 5d0873a4de4a |
| children | ea3485c67f94 |
comparison
equal
deleted
inserted
replaced
| 5983:d877a2ac5ae4 | 5984:25a813415d59 |
|---|---|
| 1983 else: | 1983 else: |
| 1984 # FIXME?? consider moving this earlier. We should | 1984 # FIXME?? consider moving this earlier. We should |
| 1985 # error out before doing any work if we can't | 1985 # error out before doing any work if we can't |
| 1986 # display acceptable output. | 1986 # display acceptable output. |
| 1987 self.client.response_code = 406 | 1987 self.client.response_code = 406 |
| 1988 output = ( "Requested content type is not available.\n" | 1988 output = ( "Requested content type '%s' is not available.\n" |
| 1989 "Acceptable types: %s"%( | 1989 "Acceptable types: %s"%(data_type, |
| 1990 ", ".join(self.__accepted_content_type.keys()))) | 1990 ", ".join(self.__accepted_content_type.keys()))) |
| 1991 | 1991 |
| 1992 # Make output json end in a newline to | 1992 # Make output json end in a newline to |
| 1993 # separate from following text in logs etc.. | 1993 # separate from following text in logs etc.. |
| 1994 return bs2b(output + "\n") | 1994 return bs2b(output + "\n") |
