📄 code.c
字号:
#include <stdlib.h>#include <stdio.h>#include <string.h>#include "wspp.h"int http_code(char status) { /* FIXME : 0x50 and 0x51 values are buggy if we do that */ return (status < 0x60 ? ((status & 0xF0) >> 4) * 100 + (status & 0x0F) : (((status - 0x10) & 0xF0) >> 4) * 100 + ((status - 0x10)& 0x0F));}char *expand_http_code(int code) {char *line; line = (char *) malloc(128); snprintf(line, 128, "HTTP/1.1 %d ", code); switch(code) { case 100: strcat(line, "Continue"); break; case 101: strcat(line, "Switching Protocols"); break; case 200: strcat(line, "OK"); break; case 201: strcat(line, "Created"); break; case 202: strcat(line, "Accepted"); break; case 203: strcat(line, "Non-Authoritative Information"); break; case 204: strcat(line, "No Content"); break; case 205: strcat(line, "Reset Content"); break; case 206: strcat(line, "Partial Content"); break; case 300: strcat(line, "Multiple Choices"); break; case 301: strcat(line, "Moved Permanently"); break; case 302: strcat(line, "Moved Temporarily"); break; case 303: strcat(line, "See Other"); break; case 304: strcat(line, "Not Modified"); break; case 305: strcat(line, "Use Proxy"); break; case 307: strcat(line, "Temporary Redirect"); break; case 400: strcat(line, "Bad Request"); break; case 401: strcat(line, "Unauthorised"); break; case 402: strcat(line, "Payment Required"); break; case 403: strcat(line, "Forbidden"); break; case 404: strcat(line, "Not Found"); break; case 405: strcat(line, "Method Not Allowed"); break; case 406: strcat(line, "Not Acceptable"); break; case 407: strcat(line, "Proxy Authentication Required"); break; case 408: strcat(line, "Request Timeout"); break; case 409: strcat(line, "Conflict"); break; case 410: strcat(line, "Gone"); break; case 411: strcat(line, "Length Required"); break; case 412: strcat(line, "Precondition Failed"); break; case 413: strcat(line, "Request Entity Too Large"); break; case 414: strcat(line, "Request-URI Too Large"); break; case 415: strcat(line, "Unsupported Media Type"); break; case 416: strcat(line, "Requested Range Not Satisfiable"); break; case 417: strcat(line, "Expectation Failed"); break; case 500: strcat(line, "Internal Server Error"); break; case 501: strcat(line, "Not Implemented"); break; case 502: strcat(line, "Bad Gateway"); break; case 503: strcat(line, "Service Unavailable"); break; case 504: strcat(line, "Gateway Timeout"); break; case 505: strcat(line, "WSP/HTTP Version Not Supported"); break; default: strcat(line, "Unknown code"); } return line;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -