提交 0ced96c8 编写于 作者: haoranc's avatar haoranc

Merge branch 'develop' of github.com:taosdata/TDengine into dev/chr

...@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS) ...@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver) #INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .) #INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED) IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.30.jar DESTINATION connector/jdbc) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.31.jar DESTINATION connector/jdbc)
ENDIF () ENDIF ()
ELSEIF (TD_DARWIN) ELSEIF (TD_DARWIN)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
......
...@@ -8,9 +8,8 @@ IF (TD_MVN_INSTALLED) ...@@ -8,9 +8,8 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
POST_BUILD POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.30.jar ${LIBRARY_OUTPUT_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.31.jar ${LIBRARY_OUTPUT_PATH}
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMENT "build jdbc driver") COMMENT "build jdbc driver")
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
ENDIF () ENDIF ()
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.30</version> <version>2.0.31</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>JDBCDriver</name> <name>JDBCDriver</name>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.30</version> <version>2.0.31</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>JDBCDriver</name> <name>JDBCDriver</name>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url> <url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
<exclude>**/InvalidResultSetPointerTest.java</exclude> <exclude>**/InvalidResultSetPointerTest.java</exclude>
<exclude>**/RestfulConnectionTest.java</exclude> <exclude>**/RestfulConnectionTest.java</exclude>
<exclude>**/TD4144Test.java</exclude> <exclude>**/TD4144Test.java</exclude>
<exclude>**/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java</exclude>
</excludes> </excludes>
<testFailureIgnore>true</testFailureIgnore> <testFailureIgnore>true</testFailureIgnore>
</configuration> </configuration>
......
...@@ -17,16 +17,18 @@ public class RestfulConnection extends AbstractConnection { ...@@ -17,16 +17,18 @@ public class RestfulConnection extends AbstractConnection {
private final int port; private final int port;
private final String url; private final String url;
private volatile String database; private volatile String database;
private final String token;
/******************************************************/ /******************************************************/
private boolean isClosed; private boolean isClosed;
private final DatabaseMetaData metadata; private final DatabaseMetaData metadata;
public RestfulConnection(String host, String port, Properties props, String database, String url) { public RestfulConnection(String host, String port, Properties props, String database, String url, String token) {
super(props); super(props);
this.host = host; this.host = host;
this.port = Integer.parseInt(port); this.port = Integer.parseInt(port);
this.database = database; this.database = database;
this.url = url; this.url = url;
this.token = token;
this.metadata = new RestfulDatabaseMetaData(url, props.getProperty(TSDBDriver.PROPERTY_KEY_USER), this); this.metadata = new RestfulDatabaseMetaData(url, props.getProperty(TSDBDriver.PROPERTY_KEY_USER), this);
} }
...@@ -66,6 +68,7 @@ public class RestfulConnection extends AbstractConnection { ...@@ -66,6 +68,7 @@ public class RestfulConnection extends AbstractConnection {
return this.metadata; return this.metadata;
} }
// getters
public String getHost() { public String getHost() {
return host; return host;
} }
...@@ -81,4 +84,8 @@ public class RestfulConnection extends AbstractConnection { ...@@ -81,4 +84,8 @@ public class RestfulConnection extends AbstractConnection {
public String getUrl() { public String getUrl() {
return url; return url;
} }
public String getToken() {
return token;
}
} }
\ No newline at end of file
...@@ -38,15 +38,11 @@ public class RestfulDriver extends AbstractDriver { ...@@ -38,15 +38,11 @@ public class RestfulDriver extends AbstractDriver {
String port = props.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "6041"); String port = props.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "6041");
String database = props.containsKey(TSDBDriver.PROPERTY_KEY_DBNAME) ? props.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME) : null; String database = props.containsKey(TSDBDriver.PROPERTY_KEY_DBNAME) ? props.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME) : null;
String loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" String loginUrl = "http://" + host + ":" + port + "/rest/login/" + props.getProperty(TSDBDriver.PROPERTY_KEY_USER) + "/" + props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD) + "";
+ props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/"
+ props.getProperty(TSDBDriver.PROPERTY_KEY_USER) + "/"
+ props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD) + "";
try { try {
String user = URLEncoder.encode(props.getProperty(TSDBDriver.PROPERTY_KEY_USER), "UTF-8"); String user = URLEncoder.encode(props.getProperty(TSDBDriver.PROPERTY_KEY_USER), "UTF-8");
String password = URLEncoder.encode(props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD), "UTF-8"); String password = URLEncoder.encode(props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD), "UTF-8");
loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" + props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/" + user + "/" + password + "";
+ props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/" + user + "/" + password + "";
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -55,12 +51,12 @@ public class RestfulDriver extends AbstractDriver { ...@@ -55,12 +51,12 @@ public class RestfulDriver extends AbstractDriver {
JSONObject jsonResult = JSON.parseObject(result); JSONObject jsonResult = JSON.parseObject(result);
String status = jsonResult.getString("status"); String status = jsonResult.getString("status");
String token = jsonResult.getString("desc"); String token = jsonResult.getString("desc");
HttpClientPoolUtil.token = token;
if (!status.equals("succ")) { if (!status.equals("succ")) {
throw new SQLException(jsonResult.getString("desc")); throw new SQLException(jsonResult.getString("desc"));
} }
RestfulConnection conn = new RestfulConnection(host, port, props, database, url); RestfulConnection conn = new RestfulConnection(host, port, props, database, url, token);
if (database != null && !database.trim().replaceAll("\\s", "").isEmpty()) { if (database != null && !database.trim().replaceAll("\\s", "").isEmpty()) {
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
stmt.execute("use " + database); stmt.execute("use " + database);
......
...@@ -83,7 +83,7 @@ public class RestfulStatement extends AbstractStatement { ...@@ -83,7 +83,7 @@ public class RestfulStatement extends AbstractStatement {
} }
if (SqlSyntaxValidator.isUseSql(sql)) { if (SqlSyntaxValidator.isUseSql(sql)) {
HttpClientPoolUtil.execute(url, sql); HttpClientPoolUtil.execute(url, sql, this.conn.getToken());
this.database = sql.trim().replace("use", "").trim(); this.database = sql.trim().replace("use", "").trim();
this.conn.setCatalog(this.database); this.conn.setCatalog(this.database);
result = false; result = false;
...@@ -116,7 +116,7 @@ public class RestfulStatement extends AbstractStatement { ...@@ -116,7 +116,7 @@ public class RestfulStatement extends AbstractStatement {
if ("UTC".equalsIgnoreCase(timestampFormat)) if ("UTC".equalsIgnoreCase(timestampFormat))
url = "http://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlutc"; url = "http://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlutc";
String result = HttpClientPoolUtil.execute(url, sql); String result = HttpClientPoolUtil.execute(url, sql, this.conn.getToken());
JSONObject resultJson = JSON.parseObject(result); JSONObject resultJson = JSON.parseObject(result);
if (resultJson.getString("status").equals("error")) { if (resultJson.getString("status").equals("error")) {
throw TSDBError.createSQLException(resultJson.getInteger("code"), resultJson.getString("desc")); throw TSDBError.createSQLException(resultJson.getInteger("code"), resultJson.getString("desc"));
...@@ -130,7 +130,7 @@ public class RestfulStatement extends AbstractStatement { ...@@ -130,7 +130,7 @@ public class RestfulStatement extends AbstractStatement {
if (!SqlSyntaxValidator.isValidForExecuteUpdate(sql)) if (!SqlSyntaxValidator.isValidForExecuteUpdate(sql))
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "not a valid sql for executeUpdate: " + sql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "not a valid sql for executeUpdate: " + sql);
String result = HttpClientPoolUtil.execute(url, sql); String result = HttpClientPoolUtil.execute(url, sql, this.conn.getToken());
JSONObject jsonObject = JSON.parseObject(result); JSONObject jsonObject = JSON.parseObject(result);
if (jsonObject.getString("status").equals("error")) { if (jsonObject.getString("status").equals("error")) {
throw TSDBError.createSQLException(jsonObject.getInteger("code"), jsonObject.getString("desc")); throw TSDBError.createSQLException(jsonObject.getInteger("code"), jsonObject.getString("desc"));
......
...@@ -20,39 +20,29 @@ import java.nio.charset.Charset; ...@@ -20,39 +20,29 @@ import java.nio.charset.Charset;
public class HttpClientPoolUtil { public class HttpClientPoolUtil {
public static PoolingHttpClientConnectionManager cm = null;
public static CloseableHttpClient httpClient = null;
public static String token = "cm9vdDp0YW9zZGF0YQ==";
/**
* 默认content 类型
*/
private static final String DEFAULT_CONTENT_TYPE = "application/json"; private static final String DEFAULT_CONTENT_TYPE = "application/json";
/** private static final String DEFAULT_TOKEN = "cm9vdDp0YW9zZGF0YQ==";
* 默认请求超时时间30s
*/
private static final int DEFAULT_TIME_OUT = 15000; private static final int DEFAULT_TIME_OUT = 15000;
private static final int count = 32; private static final int DEFAULT_MAX_PER_ROUTE = 32;
private static final int totalCount = 1000; private static final int DEFAULT_MAX_TOTAL = 1000;
private static final int Http_Default_Keep_Time = 15000; private static final int DEFAULT_HTTP_KEEP_TIME = 15000;
private static PoolingHttpClientConnectionManager connectionManager;
private static CloseableHttpClient httpClient;
/**
* 初始化连接池
*/
private static synchronized void initPools() { private static synchronized void initPools() {
if (httpClient == null) { if (httpClient == null) {
cm = new PoolingHttpClientConnectionManager(); connectionManager = new PoolingHttpClientConnectionManager();
cm.setDefaultMaxPerRoute(count); connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
cm.setMaxTotal(totalCount); connectionManager.setMaxTotal(DEFAULT_MAX_TOTAL);
httpClient = HttpClients.custom().setKeepAliveStrategy(defaultStrategy).setConnectionManager(cm).build(); httpClient = HttpClients.custom().setKeepAliveStrategy(DEFAULT_KEEP_ALIVE_STRATEGY).setConnectionManager(connectionManager).build();
} }
} }
/** private static ConnectionKeepAliveStrategy DEFAULT_KEEP_ALIVE_STRATEGY = (response, context) -> {
* Http connection keepAlive 设置
*/
private static ConnectionKeepAliveStrategy defaultStrategy = (response, context) -> {
HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE)); HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
int keepTime = Http_Default_Keep_Time * 1000; int keepTime = DEFAULT_HTTP_KEEP_TIME * 1000;
while (it.hasNext()) { while (it.hasNext()) {
HeaderElement headerElement = it.nextElement(); HeaderElement headerElement = it.nextElement();
String param = headerElement.getName(); String param = headerElement.getName();
...@@ -76,7 +66,7 @@ public class HttpClientPoolUtil { ...@@ -76,7 +66,7 @@ public class HttpClientPoolUtil {
* @param data 请求数据 * @param data 请求数据
* @return responseBody * @return responseBody
*/ */
public static String execute(String uri, String data) { public static String execute(String uri, String data, String token) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
HttpEntity httpEntity = null; HttpEntity httpEntity = null;
HttpEntityEnclosingRequestBase method = null; HttpEntityEnclosingRequestBase method = null;
......
...@@ -28,9 +28,7 @@ public class BatchInsertTest { ...@@ -28,9 +28,7 @@ public class BatchInsertTest {
@Before @Before
public void before() { public void before() {
try { try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
...@@ -44,7 +42,7 @@ public class BatchInsertTest { ...@@ -44,7 +42,7 @@ public class BatchInsertTest {
String createTableSql = "create table " + stbName + "(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))"; String createTableSql = "create table " + stbName + "(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))";
statement.executeUpdate(createTableSql); statement.executeUpdate(createTableSql);
// create tables // create tables
for(int i = 0; i < numOfTables; i++) { for (int i = 0; i < numOfTables; i++) {
String loc = i % 2 == 0 ? "beijing" : "shanghai"; String loc = i % 2 == 0 ? "beijing" : "shanghai";
String createSubTalbesSql = "create table " + tablePrefix + i + " using " + stbName + " tags(" + i + ", '" + loc + "')"; String createSubTalbesSql = "create table " + tablePrefix + i + " using " + stbName + " tags(" + i + ", '" + loc + "')";
statement.executeUpdate(createSubTalbesSql); statement.executeUpdate(createSubTalbesSql);
......
package com.taosdata.jdbc.cases;
import com.taosdata.jdbc.TSDBDriver;
import org.junit.Before;
import org.junit.Test;
import java.sql.*;
import java.util.Properties;
public class ConnectMultiTaosdByRestfulWithDifferentTokenTest {
private static String host1 = "192.168.17.156";
private static String user1 = "root";
private static String password1 = "tqueue";
private Connection conn1;
private static String host2 = "192.168.17.82";
private static String user2 = "root";
private static String password2 = "taosdata";
private Connection conn2;
@Test
public void test() {
//when
executeSelectStatus(conn1);
executeSelectStatus(conn2);
executeSelectStatus(conn1);
}
private void executeSelectStatus(Connection connection) {
try (Statement stmt = connection.createStatement()) {
ResultSet rs = stmt.executeQuery("select server_status()");
ResultSetMetaData meta = rs.getMetaData();
while (rs.next()) {
for (int i = 1; i <= meta.getColumnCount(); i++) {
System.out.println(meta.getColumnLabel(i) + ": " + rs.getString(i));
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@Before
public void before() {
Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
String url1 = "jdbc:TAOS-RS://" + host1 + ":6041/?user=" + user1 + "&password=" + password1;
String url2 = "jdbc:TAOS-RS://" + host2 + ":6041/?user=" + user2 + "&password=" + password2;
try {
conn1 = DriverManager.getConnection(url1, properties);
conn2 = DriverManager.getConnection(url2, properties);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
...@@ -19,6 +19,70 @@ ...@@ -19,6 +19,70 @@
#define HTTP_MAX_URL 5 // http url stack size #define HTTP_MAX_URL 5 // http url stack size
#define HTTP_CODE_CONTINUE 100
#define HTTP_CODE_SWITCHING_PROTOCOL 101
#define HTTP_CODE_PROCESSING 102
#define HTTP_CODE_EARLY_HINTS 103
#define HTTP_CODE_OK 200
#define HTTP_CODE_CREATED 201
#define HTTP_CODE_ACCEPTED 202
#define HTTP_CODE_NON_AUTHORITATIVE_INFO 203
#define HTTP_CODE_NO_CONTENT 204
#define HTTP_CODE_RESET_CONTENT 205
#define HTTP_CODE_PARTIAL_CONTENT 206
#define HTTP_CODE_MULTI_STATUS 207
#define HTTP_CODE_ALREADY_REPORTED 208
#define HTTP_CODE_IM_USED 226
#define HTTP_CODE_MULTIPLE_CHOICE 300
#define HTTP_CODE_MOVED_PERMANENTLY 301
#define HTTP_CODE_FOUND 302
#define HTTP_CODE_SEE_OTHER 303
#define HTTP_CODE_NOT_MODIFIED 304
#define HTTP_CODE_USE_PROXY 305
#define HTTP_CODE_UNUSED 306
#define HTTP_CODE_TEMPORARY_REDIRECT 307
#define HTTP_CODE_PERMANENT_REDIRECT 308
#define HTTP_CODE_BAD_REQUEST 400
#define HTTP_CODE_UNAUTHORIZED 401
#define HTTP_CODE_PAYMENT_REQUIRED 402
#define HTTP_CODE_FORBIDDEN 403
#define HTTP_CODE_NOT_FOUND 404
#define HTTP_CODE_METHOD_NOT_ALLOWED 405
#define HTTP_CODE_NOT_ACCEPTABLE 406
#define HTTP_CODE_PROXY_AUTH_REQUIRED 407
#define HTTP_CODE_REQUEST_TIMEOUT 408
#define HTTP_CODE_CONFLICT 409
#define HTTP_CODE_GONE 410
#define HTTP_CODE_LENGTH_REQUIRED 411
#define HTTP_CODE_PRECONDITION_FAILED 412
#define HTTP_CODE_PAYLOAD_TOO_LARGE 413
#define HTTP_CODE_URI_TOO_LARGE 414
#define HTTP_CODE_UNSUPPORTED_MEDIA_TYPE 415
#define HTTP_CODE_RANGE_NOT_SATISFIABLE 416
#define HTTP_CODE_EXPECTATION_FAILED 417
#define HTTP_CODE_IM_A_TEAPOT 418
#define HTTP_CODE_MISDIRECTED_REQUEST 421
#define HTTP_CODE_UNPROCESSABLE_ENTITY 422
#define HTTP_CODE_LOCKED 423
#define HTTP_CODE_FAILED_DEPENDENCY 424
#define HTTP_CODE_TOO_EARLY 425
#define HTTP_CODE_UPGRADE_REQUIRED 426
#define HTTP_CODE_PRECONDITION_REQUIRED 428
#define HTTP_CODE_TOO_MANY_REQUESTS 429
#define HTTP_CODE_REQ_HDR_FIELDS_TOO_LARGE 431
#define HTTP_CODE_UNAVAIL_4_LEGAL_REASONS 451
#define HTTP_CODE_INTERNAL_SERVER_ERROR 500
#define HTTP_CODE_NOT_IMPLEMENTED 501
#define HTTP_CODE_BAD_GATEWAY 502
#define HTTP_CODE_SERVICE_UNAVAILABLE 503
#define HTTP_CODE_GATEWAY_TIMEOUT 504
#define HTTP_CODE_HTTP_VER_NOT_SUPPORTED 505
#define HTTP_CODE_VARIANT_ALSO_NEGOTIATES 506
#define HTTP_CODE_INSUFFICIENT_STORAGE 507
#define HTTP_CODE_LOOP_DETECTED 508
#define HTTP_CODE_NOT_EXTENDED 510
#define HTTP_CODE_NETWORK_AUTH_REQUIRED 511
typedef enum HTTP_PARSER_STATE { typedef enum HTTP_PARSER_STATE {
HTTP_PARSER_BEGIN, HTTP_PARSER_BEGIN,
HTTP_PARSER_REQUEST_OR_RESPONSE, HTTP_PARSER_REQUEST_OR_RESPONSE,
......
...@@ -25,70 +25,70 @@ ...@@ -25,70 +25,70 @@
static void httpOnData(ehttp_gzip_t *gzip, void *arg, const char *buf, int32_t len); static void httpOnData(ehttp_gzip_t *gzip, void *arg, const char *buf, int32_t len);
static HttpStatus httpStatusCodes[] = { static HttpStatus httpStatusCodes[] = {
{100, "Continue"}, {HTTP_CODE_CONTINUE, "Continue"},
{101, "Switching Protocol"}, {HTTP_CODE_SWITCHING_PROTOCOL, "Switching Protocol"},
{102, "Processing (WebDAV)"}, {HTTP_CODE_PROCESSING, "Processing (WebDAV)"},
{103, "Early Hints"}, {HTTP_CODE_EARLY_HINTS, "Early Hints"},
{200, "OK"}, {HTTP_CODE_OK, "OK"},
{201, "Created"}, {HTTP_CODE_CREATED, "Created"},
{202, "Accepted"}, {HTTP_CODE_ACCEPTED, "Accepted"},
{203, "Non-Authoritative Information"}, {HTTP_CODE_NON_AUTHORITATIVE_INFO, "Non-Authoritative Information"},
{204, "No Content"}, {HTTP_CODE_NO_CONTENT, "No Content"},
{205, "Reset Content"}, {HTTP_CODE_RESET_CONTENT, "Reset Content"},
{206, "Partial Content"}, {HTTP_CODE_PARTIAL_CONTENT, "Partial Content"},
{207, "Multi-Status (WebDAV)"}, {HTTP_CODE_MULTI_STATUS, "Multi-Status (WebDAV)"},
{208, "Already Reported (WebDAV)"}, {HTTP_CODE_ALREADY_REPORTED, "Already Reported (WebDAV)"},
{226, "IM Used (HTTP Delta encoding)"}, {HTTP_CODE_IM_USED, "IM Used (HTTP Delta encoding)"},
{300, "Multiple Choice"}, {HTTP_CODE_MULTIPLE_CHOICE, "Multiple Choice"},
{301, "Moved Permanently"}, {HTTP_CODE_MOVED_PERMANENTLY, "Moved Permanently"},
{302, "Found"}, {HTTP_CODE_FOUND, "Found"},
{303, "See Other"}, {HTTP_CODE_SEE_OTHER, "See Other"},
{304, "Not Modified"}, {HTTP_CODE_NOT_MODIFIED, "Not Modified"},
{305, "Use Proxy"}, {HTTP_CODE_USE_PROXY, "Use Proxy"},
{306, "unused"}, {HTTP_CODE_UNUSED, "unused"},
{307, "Temporary Redirect"}, {HTTP_CODE_TEMPORARY_REDIRECT, "Temporary Redirect"},
{308, "Permanent Redirect"}, {HTTP_CODE_PERMANENT_REDIRECT, "Permanent Redirect"},
{400, "Bad Request"}, {HTTP_CODE_BAD_REQUEST, "Bad Request"},
{401, "Unauthorized"}, {HTTP_CODE_UNAUTHORIZED, "Unauthorized"},
{402, "Payment Required"}, {HTTP_CODE_PAYMENT_REQUIRED, "Payment Required"},
{403, "Forbidden"}, {HTTP_CODE_FORBIDDEN, "Forbidden"},
{404, "Not Found"}, {HTTP_CODE_NOT_FOUND, "Not Found"},
{405, "Method Not Allowed"}, {HTTP_CODE_METHOD_NOT_ALLOWED, "Method Not Allowed"},
{406, "Not Acceptable"}, {HTTP_CODE_NOT_ACCEPTABLE, "Not Acceptable"},
{407, "Proxy Authentication Required"}, {HTTP_CODE_PROXY_AUTH_REQUIRED, "Proxy Authentication Required"},
{408, "Request Timeout"}, {HTTP_CODE_REQUEST_TIMEOUT, "Request Timeout"},
{409, "Conflict"}, {HTTP_CODE_CONFLICT, "Conflict"},
{410, "Gone"}, {HTTP_CODE_GONE, "Gone"},
{411, "Length Required"}, {HTTP_CODE_LENGTH_REQUIRED, "Length Required"},
{412, "Precondition Failed"}, {HTTP_CODE_PRECONDITION_FAILED, "Precondition Failed"},
{413, "Payload Too Large"}, {HTTP_CODE_PAYLOAD_TOO_LARGE, "Payload Too Large"},
{414, "URI Too Long"}, {HTTP_CODE_URI_TOO_LARGE, "URI Too Long"},
{415, "Unsupported Media Type"}, {HTTP_CODE_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type"},
{416, "Range Not Satisfiable"}, {HTTP_CODE_RANGE_NOT_SATISFIABLE, "Range Not Satisfiable"},
{417, "Expectation Failed"}, {HTTP_CODE_EXPECTATION_FAILED, "Expectation Failed"},
{418, "I'm a teapot"}, {HTTP_CODE_IM_A_TEAPOT, "I'm a teapot"},
{421, "Misdirected Request"}, {HTTP_CODE_MISDIRECTED_REQUEST, "Misdirected Request"},
{422, "Unprocessable Entity (WebDAV)"}, {HTTP_CODE_UNPROCESSABLE_ENTITY, "Unprocessable Entity (WebDAV)"},
{423, "Locked (WebDAV)"}, {HTTP_CODE_LOCKED, "Locked (WebDAV)"},
{424, "Failed Dependency (WebDAV)"}, {HTTP_CODE_FAILED_DEPENDENCY, "Failed Dependency (WebDAV)"},
{425, "Too Early"}, {HTTP_CODE_TOO_EARLY, "Too Early"},
{426, "Upgrade Required"}, {HTTP_CODE_UPGRADE_REQUIRED, "Upgrade Required"},
{428, "Precondition Required"}, {HTTP_CODE_PRECONDITION_REQUIRED, "Precondition Required"},
{429, "Too Many Requests"}, {HTTP_CODE_TOO_MANY_REQUESTS, "Too Many Requests"},
{431, "Request Header Fields Too Large"}, {HTTP_CODE_REQ_HDR_FIELDS_TOO_LARGE,"Request Header Fields Too Large"},
{451, "Unavailable For Legal Reasons"}, {HTTP_CODE_UNAVAIL_4_LEGAL_REASONS, "Unavailable For Legal Reasons"},
{500, "Internal Server Error"}, {HTTP_CODE_INTERNAL_SERVER_ERROR, "Internal Server Error"},
{501, "Not Implemented"}, {HTTP_CODE_NOT_IMPLEMENTED, "Not Implemented"},
{502, "Bad Gateway"}, {HTTP_CODE_BAD_GATEWAY, "Bad Gateway"},
{503, "Service Unavailable"}, {HTTP_CODE_SERVICE_UNAVAILABLE, "Service Unavailable"},
{504, "Gateway Timeout"}, {HTTP_CODE_GATEWAY_TIMEOUT, "Gateway Timeout"},
{505, "HTTP Version Not Supported"}, {HTTP_CODE_HTTP_VER_NOT_SUPPORTED, "HTTP Version Not Supported"},
{506, "Variant Also Negotiates"}, {HTTP_CODE_VARIANT_ALSO_NEGOTIATES, "Variant Also Negotiates"},
{507, "Insufficient Storage"}, {HTTP_CODE_INSUFFICIENT_STORAGE, "Insufficient Storage"},
{508, "Loop Detected (WebDAV)"}, {HTTP_CODE_LOOP_DETECTED, "Loop Detected (WebDAV)"},
{510, "Not Extended"}, {HTTP_CODE_NOT_EXTENDED, "Not Extended"},
{511, "Network Authentication Required"}, {HTTP_CODE_NETWORK_AUTH_REQUIRED, "Network Authentication Required"},
{0, NULL} {0, NULL}
}; };
char *httpGetStatusDesc(int32_t statusCode) { char *httpGetStatusDesc(int32_t statusCode) {
...@@ -552,7 +552,7 @@ static int32_t httpParserOnBegin(HttpParser *parser, HTTP_PARSER_STATE state, co ...@@ -552,7 +552,7 @@ static int32_t httpParserOnBegin(HttpParser *parser, HTTP_PARSER_STATE state, co
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_METHOD_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_METHOD_FAILED);
break; break;
} }
httpPopStack(parser); httpPopStack(parser);
...@@ -561,7 +561,7 @@ static int32_t httpParserOnBegin(HttpParser *parser, HTTP_PARSER_STATE state, co ...@@ -561,7 +561,7 @@ static int32_t httpParserOnBegin(HttpParser *parser, HTTP_PARSER_STATE state, co
} }
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_METHOD_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_METHOD_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -599,7 +599,7 @@ static int32_t httpParserOnRquestOrResponse(HttpParser *parser, HTTP_PARSER_STAT ...@@ -599,7 +599,7 @@ static int32_t httpParserOnRquestOrResponse(HttpParser *parser, HTTP_PARSER_STAT
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_METHOD_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_METHOD_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -612,7 +612,7 @@ static int32_t httpParserOnMethod(HttpParser *parser, HTTP_PARSER_STATE state, c ...@@ -612,7 +612,7 @@ static int32_t httpParserOnMethod(HttpParser *parser, HTTP_PARSER_STATE state, c
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_METHOD_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_METHOD_FAILED);
break; break;
} }
break; break;
...@@ -621,7 +621,7 @@ static int32_t httpParserOnMethod(HttpParser *parser, HTTP_PARSER_STATE state, c ...@@ -621,7 +621,7 @@ static int32_t httpParserOnMethod(HttpParser *parser, HTTP_PARSER_STATE state, c
if (!parser->method) { if (!parser->method) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_METHOD_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_METHOD_FAILED);
break; break;
} else { } else {
httpTrace("context:%p, fd:%d, httpMethod:%s", pContext, pContext->fd, parser->method); httpTrace("context:%p, fd:%d, httpMethod:%s", pContext, pContext->fd, parser->method);
...@@ -641,7 +641,7 @@ static int32_t httpParserOnTarget(HttpParser *parser, HTTP_PARSER_STATE state, c ...@@ -641,7 +641,7 @@ static int32_t httpParserOnTarget(HttpParser *parser, HTTP_PARSER_STATE state, c
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_TARGET_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_TARGET_FAILED);
break; break;
} }
break; break;
...@@ -650,7 +650,7 @@ static int32_t httpParserOnTarget(HttpParser *parser, HTTP_PARSER_STATE state, c ...@@ -650,7 +650,7 @@ static int32_t httpParserOnTarget(HttpParser *parser, HTTP_PARSER_STATE state, c
if (!parser->target) { if (!parser->target) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_TARGET_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_TARGET_FAILED);
break; break;
} }
httpClearString(&parser->str); httpClearString(&parser->str);
...@@ -670,13 +670,13 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, ...@@ -670,13 +670,13 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state,
if (prefix[parser->str.pos] != c) { if (prefix[parser->str.pos] != c) {
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_VERSION_FAILED);
break; break;
} }
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_VERSION_FAILED);
break; break;
} }
break; break;
...@@ -685,14 +685,14 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, ...@@ -685,14 +685,14 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state,
if (c != '0' && c != '1' && c != '2') { if (c != '0' && c != '1' && c != '2') {
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_VERSION_FAILED);
break; break;
} }
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_VERSION_FAILED);
break; break;
} }
...@@ -709,7 +709,7 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, ...@@ -709,7 +709,7 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state,
if (!parser->version) { if (!parser->version) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_VERSION_FAILED);
break; break;
} }
...@@ -739,7 +739,7 @@ static int32_t httpParserOnSp(HttpParser *parser, HTTP_PARSER_STATE state, const ...@@ -739,7 +739,7 @@ static int32_t httpParserOnSp(HttpParser *parser, HTTP_PARSER_STATE state, const
} }
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_SP_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_SP_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -752,7 +752,7 @@ static int32_t httpParserOnStatusCode(HttpParser *parser, HTTP_PARSER_STATE stat ...@@ -752,7 +752,7 @@ static int32_t httpParserOnStatusCode(HttpParser *parser, HTTP_PARSER_STATE stat
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_STATUS_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_STATUS_FAILED);
break; break;
} }
if (parser->str.pos < 3) break; if (parser->str.pos < 3) break;
...@@ -764,7 +764,7 @@ static int32_t httpParserOnStatusCode(HttpParser *parser, HTTP_PARSER_STATE stat ...@@ -764,7 +764,7 @@ static int32_t httpParserOnStatusCode(HttpParser *parser, HTTP_PARSER_STATE stat
} }
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_STATUS_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_STATUS_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -778,7 +778,7 @@ static int32_t httpParserOnReasonPhrase(HttpParser *parser, HTTP_PARSER_STATE st ...@@ -778,7 +778,7 @@ static int32_t httpParserOnReasonPhrase(HttpParser *parser, HTTP_PARSER_STATE st
if (!parser->reasonPhrase) { if (!parser->reasonPhrase) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_PHRASE_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_PHRASE_FAILED);
break; break;
} }
ok = httpOnStatusLine(parser, parser->statusCode, parser->reasonPhrase); ok = httpOnStatusLine(parser, parser->statusCode, parser->reasonPhrase);
...@@ -790,7 +790,7 @@ static int32_t httpParserOnReasonPhrase(HttpParser *parser, HTTP_PARSER_STATE st ...@@ -790,7 +790,7 @@ static int32_t httpParserOnReasonPhrase(HttpParser *parser, HTTP_PARSER_STATE st
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_PHRASE_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_PHRASE_FAILED);
break; break;
} }
} while (0); } while (0);
...@@ -802,7 +802,7 @@ static int32_t httpParserPostProcess(HttpParser *parser) { ...@@ -802,7 +802,7 @@ static int32_t httpParserPostProcess(HttpParser *parser) {
if (parser->gzip) { if (parser->gzip) {
if (ehttp_gzip_finish(parser->gzip)) { if (ehttp_gzip_finish(parser->gzip)) {
httpError("context:%p, fd:%d, gzip failed", pContext, pContext->fd); httpError("context:%p, fd:%d, gzip failed", pContext, pContext->fd);
httpOnError(parser, 507, TSDB_CODE_HTTP_FINISH_GZIP_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_FINISH_GZIP_FAILED);
return -1; return -1;
} }
} }
...@@ -819,13 +819,13 @@ static int32_t httpParserOnCrlf(HttpParser *parser, HTTP_PARSER_STATE state, con ...@@ -819,13 +819,13 @@ static int32_t httpParserOnCrlf(HttpParser *parser, HTTP_PARSER_STATE state, con
if (s[parser->str.pos] != c) { if (s[parser->str.pos] != c) {
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_CRLF_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_CRLF_FAILED);
break; break;
} }
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_CRLF_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_CRLF_FAILED);
break; break;
} }
if (parser->str.pos == len) { if (parser->str.pos == len) {
...@@ -862,7 +862,7 @@ static int32_t httpParserOnHeader(HttpParser *parser, HTTP_PARSER_STATE state, c ...@@ -862,7 +862,7 @@ static int32_t httpParserOnHeader(HttpParser *parser, HTTP_PARSER_STATE state, c
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_HEADER_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_HEADER_FAILED);
break; break;
} }
httpPushStack(parser, HTTP_PARSER_CRLF); httpPushStack(parser, HTTP_PARSER_CRLF);
...@@ -873,7 +873,7 @@ static int32_t httpParserOnHeader(HttpParser *parser, HTTP_PARSER_STATE state, c ...@@ -873,7 +873,7 @@ static int32_t httpParserOnHeader(HttpParser *parser, HTTP_PARSER_STATE state, c
} }
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_HEADER_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_HEADER_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -886,7 +886,7 @@ static int32_t httpParserOnHeaderKey(HttpParser *parser, HTTP_PARSER_STATE state ...@@ -886,7 +886,7 @@ static int32_t httpParserOnHeaderKey(HttpParser *parser, HTTP_PARSER_STATE state
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED);
break; break;
} }
break; break;
...@@ -896,7 +896,7 @@ static int32_t httpParserOnHeaderKey(HttpParser *parser, HTTP_PARSER_STATE state ...@@ -896,7 +896,7 @@ static int32_t httpParserOnHeaderKey(HttpParser *parser, HTTP_PARSER_STATE state
if (!parser->key) { if (!parser->key) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED);
break; break;
} }
httpClearString(&parser->str); httpClearString(&parser->str);
...@@ -905,7 +905,7 @@ static int32_t httpParserOnHeaderKey(HttpParser *parser, HTTP_PARSER_STATE state ...@@ -905,7 +905,7 @@ static int32_t httpParserOnHeaderKey(HttpParser *parser, HTTP_PARSER_STATE state
} }
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -919,7 +919,7 @@ static int32_t httpParserOnHeaderVal(HttpParser *parser, HTTP_PARSER_STATE state ...@@ -919,7 +919,7 @@ static int32_t httpParserOnHeaderVal(HttpParser *parser, HTTP_PARSER_STATE state
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
parser->parseCode = TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED; parser->parseCode = TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED);
break; break;
} }
break; break;
...@@ -948,7 +948,7 @@ static int32_t httpParserOnChunkSize(HttpParser *parser, HTTP_PARSER_STATE state ...@@ -948,7 +948,7 @@ static int32_t httpParserOnChunkSize(HttpParser *parser, HTTP_PARSER_STATE state
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED);
break; break;
} }
break; break;
...@@ -982,7 +982,7 @@ static int32_t httpParserOnChunkSize(HttpParser *parser, HTTP_PARSER_STATE state ...@@ -982,7 +982,7 @@ static int32_t httpParserOnChunkSize(HttpParser *parser, HTTP_PARSER_STATE state
} }
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED); httpOnError(parser, HTTP_CODE_BAD_REQUEST, TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -994,7 +994,7 @@ static int32_t httpParserOnChunk(HttpParser *parser, HTTP_PARSER_STATE state, co ...@@ -994,7 +994,7 @@ static int32_t httpParserOnChunk(HttpParser *parser, HTTP_PARSER_STATE state, co
if (httpAppendString(&parser->str, &c, 1)) { if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_CHUNK_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_CHUNK_FAILED);
break; break;
} }
++parser->receivedSize; ++parser->receivedSize;
...@@ -1005,7 +1005,7 @@ static int32_t httpParserOnChunk(HttpParser *parser, HTTP_PARSER_STATE state, co ...@@ -1005,7 +1005,7 @@ static int32_t httpParserOnChunk(HttpParser *parser, HTTP_PARSER_STATE state, co
if (ehttp_gzip_write(parser->gzip, parser->str.str, parser->str.pos)) { if (ehttp_gzip_write(parser->gzip, parser->str.str, parser->str.pos)) {
httpError("context:%p, fd:%d, gzip failed", pContext, pContext->fd); httpError("context:%p, fd:%d, gzip failed", pContext, pContext->fd);
ok = -1; ok = -1;
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_CHUNK_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_CHUNK_FAILED);
break; break;
} }
} else { } else {
...@@ -1027,7 +1027,7 @@ static int32_t httpParserOnEnd(HttpParser *parser, HTTP_PARSER_STATE state, cons ...@@ -1027,7 +1027,7 @@ static int32_t httpParserOnEnd(HttpParser *parser, HTTP_PARSER_STATE state, cons
do { do {
ok = -1; ok = -1;
httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c);
httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_END_FAILED); httpOnError(parser, HTTP_CODE_INSUFFICIENT_STORAGE, TSDB_CODE_HTTP_PARSE_END_FAILED);
} while (0); } while (0);
return ok; return ok;
} }
...@@ -1104,7 +1104,7 @@ static int32_t httpParseChar(HttpParser *parser, const char c, int32_t *again) { ...@@ -1104,7 +1104,7 @@ static int32_t httpParseChar(HttpParser *parser, const char c, int32_t *again) {
ok = -1; ok = -1;
httpError("context:%p, fd:%d, unknown parse state:%d", pContext, pContext->fd, state); httpError("context:%p, fd:%d, unknown parse state:%d", pContext, pContext->fd, state);
httpOnError(parser, 500, TSDB_CODE_HTTP_PARSE_INVALID_STATE); httpOnError(parser, HTTP_CODE_INTERNAL_SERVER_ERROR, TSDB_CODE_HTTP_PARSE_INVALID_STATE);
} while (0); } while (0);
if (ok == -1) { if (ok == -1) {
...@@ -1115,7 +1115,7 @@ static int32_t httpParseChar(HttpParser *parser, const char c, int32_t *again) { ...@@ -1115,7 +1115,7 @@ static int32_t httpParseChar(HttpParser *parser, const char c, int32_t *again) {
if (ok == -2) { if (ok == -2) {
ok = -1; ok = -1;
httpError("context:%p, fd:%d, failed to parse, invalid state", pContext, pContext->fd); httpError("context:%p, fd:%d, failed to parse, invalid state", pContext, pContext->fd);
httpOnError(parser, 500, TSDB_CODE_HTTP_PARSE_ERROR_STATE); httpOnError(parser, HTTP_CODE_INTERNAL_SERVER_ERROR, TSDB_CODE_HTTP_PARSE_ERROR_STATE);
} }
return ok; return ok;
......
...@@ -67,81 +67,81 @@ static void httpSendErrorRespImp(HttpContext *pContext, int32_t httpCode, char * ...@@ -67,81 +67,81 @@ static void httpSendErrorRespImp(HttpContext *pContext, int32_t httpCode, char *
} }
void httpSendErrorResp(HttpContext *pContext, int32_t errNo) { void httpSendErrorResp(HttpContext *pContext, int32_t errNo) {
int32_t httpCode = 500; int32_t httpCode = HTTP_CODE_INTERNAL_SERVER_ERROR;
if (errNo == TSDB_CODE_SUCCESS) if (errNo == TSDB_CODE_SUCCESS)
httpCode = 200; httpCode = HTTP_CODE_OK;
else if (errNo == TSDB_CODE_HTTP_SERVER_OFFLINE) else if (errNo == TSDB_CODE_HTTP_SERVER_OFFLINE)
httpCode = 404; httpCode = HTTP_CODE_NOT_FOUND;
else if (errNo == TSDB_CODE_HTTP_UNSUPPORT_URL) else if (errNo == TSDB_CODE_HTTP_UNSUPPORT_URL)
httpCode = 404; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_INVALID_URL) else if (errNo == TSDB_CODE_HTTP_INVALID_URL)
httpCode = 404; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_NO_ENOUGH_MEMORY) else if (errNo == TSDB_CODE_HTTP_NO_ENOUGH_MEMORY)
httpCode = 507; httpCode = HTTP_CODE_INSUFFICIENT_STORAGE;
else if (errNo == TSDB_CODE_HTTP_REQUSET_TOO_BIG) else if (errNo == TSDB_CODE_HTTP_REQUSET_TOO_BIG)
httpCode = 413; httpCode = HTTP_CODE_PAYLOAD_TOO_LARGE;
else if (errNo == TSDB_CODE_HTTP_NO_AUTH_INFO) else if (errNo == TSDB_CODE_HTTP_NO_AUTH_INFO)
httpCode = 401; httpCode = HTTP_CODE_UNAUTHORIZED;
else if (errNo == TSDB_CODE_HTTP_NO_MSG_INPUT) else if (errNo == TSDB_CODE_HTTP_NO_MSG_INPUT)
httpCode = 400; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_NO_SQL_INPUT) else if (errNo == TSDB_CODE_HTTP_NO_SQL_INPUT)
httpCode = 400; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_NO_EXEC_USEDB) else if (errNo == TSDB_CODE_HTTP_NO_EXEC_USEDB)
httpCode = 400; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_SESSION_FULL) else if (errNo == TSDB_CODE_HTTP_SESSION_FULL)
httpCode = 421; httpCode = HTTP_CODE_INTERNAL_SERVER_ERROR;
else if (errNo == TSDB_CODE_HTTP_GEN_TAOSD_TOKEN_ERR) else if (errNo == TSDB_CODE_HTTP_GEN_TAOSD_TOKEN_ERR)
httpCode = 507; httpCode = HTTP_CODE_INTERNAL_SERVER_ERROR;
else if (errNo == TSDB_CODE_HTTP_INVALID_MULTI_REQUEST) else if (errNo == TSDB_CODE_HTTP_INVALID_MULTI_REQUEST)
httpCode = 400; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_CREATE_GZIP_FAILED) else if (errNo == TSDB_CODE_HTTP_CREATE_GZIP_FAILED)
httpCode = 507; httpCode = HTTP_CODE_INTERNAL_SERVER_ERROR;
else if (errNo == TSDB_CODE_HTTP_FINISH_GZIP_FAILED) else if (errNo == TSDB_CODE_HTTP_FINISH_GZIP_FAILED)
httpCode = 507; httpCode = HTTP_CODE_INTERNAL_SERVER_ERROR;
else if (errNo == TSDB_CODE_HTTP_INVALID_VERSION) else if (errNo == TSDB_CODE_HTTP_INVALID_VERSION)
httpCode = 406; httpCode = HTTP_CODE_HTTP_VER_NOT_SUPPORTED;
else if (errNo == TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH) else if (errNo == TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH)
httpCode = 406; httpCode = HTTP_CODE_LENGTH_REQUIRED;
else if (errNo == TSDB_CODE_HTTP_INVALID_AUTH_TYPE) else if (errNo == TSDB_CODE_HTTP_INVALID_AUTH_TYPE)
httpCode = 406; httpCode = HTTP_CODE_UNAUTHORIZED;
else if (errNo == TSDB_CODE_HTTP_INVALID_AUTH_FORMAT) else if (errNo == TSDB_CODE_HTTP_INVALID_AUTH_FORMAT)
httpCode = 406; httpCode = HTTP_CODE_UNAUTHORIZED;
else if (errNo == TSDB_CODE_HTTP_INVALID_BASIC_AUTH) else if (errNo == TSDB_CODE_HTTP_INVALID_BASIC_AUTH)
httpCode = 406; httpCode = HTTP_CODE_UNAUTHORIZED;
else if (errNo == TSDB_CODE_HTTP_INVALID_TAOSD_AUTH) else if (errNo == TSDB_CODE_HTTP_INVALID_TAOSD_AUTH)
httpCode = 406; httpCode = HTTP_CODE_UNAUTHORIZED;
else if (errNo == TSDB_CODE_HTTP_PARSE_METHOD_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_METHOD_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_TARGET_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_TARGET_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_VERSION_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_VERSION_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_SP_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_SP_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_STATUS_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_STATUS_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_PHRASE_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_PHRASE_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_CRLF_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_CRLF_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_HEADER_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_HEADER_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_CHUNK_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_CHUNK_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_END_FAILED) else if (errNo == TSDB_CODE_HTTP_PARSE_END_FAILED)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_INVALID_STATE) else if (errNo == TSDB_CODE_HTTP_PARSE_INVALID_STATE)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else if (errNo == TSDB_CODE_HTTP_PARSE_ERROR_STATE) else if (errNo == TSDB_CODE_HTTP_PARSE_ERROR_STATE)
httpCode = 406; httpCode = HTTP_CODE_BAD_REQUEST;
else else
httpCode = 400; httpCode = HTTP_CODE_BAD_REQUEST;
if (pContext->parser && pContext->parser->httpCode != 0) { if (pContext->parser && pContext->parser->httpCode != 0) {
httpCode = pContext->parser->httpCode; httpCode = pContext->parser->httpCode;
...@@ -152,7 +152,7 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) { ...@@ -152,7 +152,7 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) {
} }
void httpSendTaosdInvalidSqlErrorResp(HttpContext *pContext, char *errMsg) { void httpSendTaosdInvalidSqlErrorResp(HttpContext *pContext, char *errMsg) {
int32_t httpCode = 400; int32_t httpCode = HTTP_CODE_BAD_REQUEST;
char temp[512] = {0}; char temp[512] = {0};
int32_t len = sprintf(temp, "invalid SQL: %s", errMsg); int32_t len = sprintf(temp, "invalid SQL: %s", errMsg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册