[asterisk-commits] dlee: trunk r395136 - in /trunk: res/ rest-api-templates/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 23 09:57:05 CDT 2013


Author: dlee
Date: Tue Jul 23 09:57:03 2013
New Revision: 395136

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395136
Log:
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.

Modified:
    trunk/res/res_stasis_http.c
    trunk/res/res_stasis_http_asterisk.c
    trunk/res/res_stasis_http_bridges.c
    trunk/res/res_stasis_http_channels.c
    trunk/res/res_stasis_http_endpoints.c
    trunk/res/res_stasis_http_playback.c
    trunk/res/res_stasis_http_recordings.c
    trunk/res/res_stasis_http_sounds.c
    trunk/rest-api-templates/res_stasis_http_resource.c.mustache

Modified: trunk/res/res_stasis_http.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http.c (original)
+++ trunk/res/res_stasis_http.c Tue Jul 23 09:57:03 2013
@@ -545,9 +545,10 @@
 	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");
 	}
 }

Modified: trunk/res/res_stasis_http_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_asterisk.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_asterisk.c (original)
+++ trunk/res/res_stasis_http_asterisk.c Tue Jul 23 09:57:03 2013
@@ -78,7 +78,11 @@
 	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 @@
 	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 @@
 	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:

Modified: trunk/res/res_stasis_http_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_bridges.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_bridges.c (original)
+++ trunk/res/res_stasis_http_bridges.c Tue Jul 23 09:57:03 2013
@@ -70,7 +70,11 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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:

Modified: trunk/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_channels.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_channels.c (original)
+++ trunk/res/res_stasis_http_channels.c Tue Jul 23 09:57:03 2013
@@ -70,7 +70,11 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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;

Modified: trunk/res/res_stasis_http_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_endpoints.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_endpoints.c (original)
+++ trunk/res/res_stasis_http_endpoints.c Tue Jul 23 09:57:03 2013
@@ -70,7 +70,11 @@
 	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 @@
 	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 @@
 	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:

Modified: trunk/res/res_stasis_http_playback.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_playback.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_playback.c (original)
+++ trunk/res/res_stasis_http_playback.c Tue Jul 23 09:57:03 2013
@@ -78,7 +78,11 @@
 	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 @@
 	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 @@
 	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 */

Modified: trunk/res/res_stasis_http_recordings.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_recordings.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_recordings.c (original)
+++ trunk/res/res_stasis_http_recordings.c Tue Jul 23 09:57:03 2013
@@ -70,7 +70,11 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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:

Modified: trunk/res/res_stasis_http_sounds.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis_http_sounds.c?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/res/res_stasis_http_sounds.c (original)
+++ trunk/res/res_stasis_http_sounds.c Tue Jul 23 09:57:03 2013
@@ -81,7 +81,11 @@
 	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 @@
 	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:

Modified: trunk/rest-api-templates/res_stasis_http_resource.c.mustache
URL: http://svnview.digium.com/svn/asterisk/trunk/rest-api-templates/res_stasis_http_resource.c.mustache?view=diff&rev=395136&r1=395135&r2=395136
==============================================================================
--- trunk/rest-api-templates/res_stasis_http_resource.c.mustache (original)
+++ trunk/rest-api-templates/res_stasis_http_resource.c.mustache Tue Jul 23 09:57:03 2013
@@ -78,7 +78,11 @@
 	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}}




More information about the asterisk-commits mailing list