No more teapots.

Now that the ARI implementation is nearing some definition of
completeness, we should properly respond with 501's for unimplemented
functionality, instead of the almost humorous 418.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395136 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee 2013-07-23 14:57:03 +00:00
parent ff2f5eaa23
commit e148c6e867
9 changed files with 243 additions and 50 deletions

View File

@ -545,9 +545,10 @@ void stasis_http_invoke(struct ast_tcptls_session_instance *ser,
callback(get_params, path_vars, headers, response);
if (response->message == NULL && response->response_code == 0) {
/* Really should not happen */
ast_assert(0);
ast_log(LOG_ERROR, "ARI %s %s not implemented\n",
ast_get_http_method(method), uri);
stasis_http_response_error(
response, 418, "I'm a teapot",
response, 501, "Not Implemented",
"Method not implemented");
}
}

View File

@ -78,7 +78,11 @@ static void stasis_http_get_asterisk_info_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -128,7 +132,11 @@ static void stasis_http_get_global_var_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -181,7 +189,11 @@ static void stasis_http_set_global_var_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:

View File

@ -70,7 +70,11 @@ static void stasis_http_get_bridges_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -120,7 +124,11 @@ static void stasis_http_new_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -170,7 +178,11 @@ static void stasis_http_get_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Bridge not found */
is_valid = 1;
break;
@ -221,7 +233,11 @@ static void stasis_http_delete_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Bridge not found */
is_valid = 1;
break;
@ -278,7 +294,11 @@ static void stasis_http_add_channel_to_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Bridge not found */
case 409: /* Bridge not in Stasis application */
case 422: /* Channel not found, or not in Stasis application */
@ -337,7 +357,11 @@ static void stasis_http_remove_channel_from_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -402,7 +426,11 @@ static void stasis_http_play_on_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Bridge not found */
case 409: /* Bridge not in a Stasis application */
is_valid = 1;
@ -478,7 +506,11 @@ static void stasis_http_record_bridge_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:

View File

@ -70,7 +70,11 @@ static void stasis_http_get_channels_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -141,7 +145,11 @@ static void stasis_http_originate_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 400: /* Invalid parameters for originating a channel. */
is_valid = 1;
break;
@ -192,7 +200,11 @@ static void stasis_http_get_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
is_valid = 1;
break;
@ -243,7 +255,11 @@ static void stasis_http_delete_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
is_valid = 1;
break;
@ -309,7 +325,11 @@ static void stasis_http_dial_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -373,7 +393,11 @@ static void stasis_http_continue_in_dialplan_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -425,7 +449,11 @@ static void stasis_http_answer_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -483,7 +511,11 @@ static void stasis_http_mute_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -541,7 +573,11 @@ static void stasis_http_unmute_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -593,7 +629,11 @@ static void stasis_http_hold_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -645,7 +685,11 @@ static void stasis_http_unhold_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -703,7 +747,11 @@ static void stasis_http_moh_start_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -755,7 +803,11 @@ static void stasis_http_moh_stop_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -822,7 +874,11 @@ static void stasis_http_play_on_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -898,7 +954,11 @@ static void stasis_http_record_channel_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 400: /* Invalid parameters */
case 404: /* Channel not found */
case 409: /* Channel is not in a Stasis application; the channel is currently bridged with other channels; A recording with the same name is currently in progress. */
@ -957,7 +1017,11 @@ static void stasis_http_get_channel_var_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;
@ -1018,7 +1082,11 @@ static void stasis_http_set_channel_var_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
is_valid = 1;

View File

@ -70,7 +70,11 @@ static void stasis_http_get_endpoints_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -120,7 +124,11 @@ static void stasis_http_get_endpoints_by_tech_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -173,7 +181,11 @@ static void stasis_http_get_endpoint_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:

View File

@ -78,7 +78,11 @@ static void stasis_http_get_playback_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -128,7 +132,11 @@ static void stasis_http_stop_playback_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -184,7 +192,11 @@ static void stasis_http_control_playback_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 400: /* The provided operation parameter was invalid */
case 404: /* The playback cannot be found */
case 409: /* The operation cannot be performed in the playback's current state */

View File

@ -70,7 +70,11 @@ static void stasis_http_get_stored_recordings_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -120,7 +124,11 @@ static void stasis_http_get_stored_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -170,7 +178,11 @@ static void stasis_http_delete_stored_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -212,7 +224,11 @@ static void stasis_http_get_live_recordings_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -262,7 +278,11 @@ static void stasis_http_get_live_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -312,7 +332,11 @@ static void stasis_http_cancel_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -362,7 +386,11 @@ static void stasis_http_stop_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -412,7 +440,11 @@ static void stasis_http_pause_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -462,7 +494,11 @@ static void stasis_http_unpause_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -512,7 +548,11 @@ static void stasis_http_mute_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -562,7 +602,11 @@ static void stasis_http_unmute_recording_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:

View File

@ -81,7 +81,11 @@ static void stasis_http_get_sounds_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
@ -131,7 +135,11 @@ static void stasis_http_get_stored_sound_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:

View File

@ -78,7 +78,11 @@ static void stasis_http_{{c_nickname}}_cb(
code = response->response_code;
switch (code) {
case 500: /* Internal server error */
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
{{#error_responses}}
case {{code}}: /* {{{reason}}} */
{{/error_responses}}