26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include "error.h" |
29 #include "error.h" |
30 |
30 |
31 #include <ucx/string.h> |
31 #include <cx/string.h> |
32 #include "../util/pblock.h" |
32 #include "../util/pblock.h" |
33 #include "../util/strbuf.h" |
33 #include "../util/strbuf.h" |
34 |
34 |
35 // macro for creating an error string (ucx sstr_t) |
35 // macro for creating an error string (ucx cxmutstr) |
36 #define ERRMSG(s) { s, sizeof(s)-1 } |
36 #define ERRMSG(s) { s, sizeof(s)-1 } |
37 |
37 |
38 static sstr_t error_400 = ERRMSG("<html><body>bad request</body></html>"); |
38 static cxmutstr error_400 = ERRMSG("<html><body>bad request</body></html>"); |
39 static sstr_t error_403 = ERRMSG("<html><body>forbidden</body></html>"); |
39 static cxmutstr error_403 = ERRMSG("<html><body>forbidden</body></html>"); |
40 static sstr_t error_404 = ERRMSG("<html><body>not found</body></html>"); |
40 static cxmutstr error_404 = ERRMSG("<html><body>not found</body></html>"); |
41 static sstr_t error_500 = ERRMSG("<html><body>server error</body></html>"); |
41 static cxmutstr error_500 = ERRMSG("<html><body>server error</body></html>"); |
42 static sstr_t error_503 = ERRMSG("<html><body>service unavailable</body></html>"); |
42 static cxmutstr error_503 = ERRMSG("<html><body>service unavailable</body></html>"); |
43 |
43 |
44 static sstr_t error_std = ERRMSG("<html><body>error</body></html>"); |
44 static cxmutstr error_std = ERRMSG("<html><body>error</body></html>"); |
45 |
45 |
46 int nsapi_error_request(Session *sn, Request *rq) { |
46 int nsapi_error_request(Session *sn, Request *rq) { |
47 short status = rq->status_num; |
47 short status = rq->status_num; |
48 sstr_t msg; |
48 cxmutstr msg; |
49 if(status < 400) { |
49 if(status < 400) { |
50 msg.ptr = NULL; |
50 msg.ptr = NULL; |
51 msg.length = 0; |
51 msg.length = 0; |
52 } else { |
52 } else { |
53 switch(status) { |
53 switch(status) { |