Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
97277ed6
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97277ed6
编写于
9月 25, 2017
作者:
V
Vitaliy Lyudvichenko
提交者:
alexey-milovidov
9月 30, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return 411 code in case of empty body without Content-Length head. [#CLICKHOUSE-3333]
上级
4e4355a2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
13 deletion
+17
-13
dbms/src/Core/ErrorCodes.cpp
dbms/src/Core/ErrorCodes.cpp
+1
-0
dbms/src/Server/HTTPHandler.cpp
dbms/src/Server/HTTPHandler.cpp
+13
-9
dbms/tests/queries/0_stateless/00501_http_head.reference
dbms/tests/queries/0_stateless/00501_http_head.reference
+0
-2
dbms/tests/queries/0_stateless/00501_http_head.sh
dbms/tests/queries/0_stateless/00501_http_head.sh
+3
-2
未找到文件。
dbms/src/Core/ErrorCodes.cpp
浏览文件 @
97277ed6
...
...
@@ -383,6 +383,7 @@ namespace ErrorCodes
extern
const
int
DATA_TYPE_CANNOT_HAVE_ARGUMENTS
=
378
;
extern
const
int
UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK
=
379
;
extern
const
int
CANNOT_KILL
=
380
;
extern
const
int
HTTP_LENGTH_REQUIRED
=
381
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
extern
const
int
POCO_EXCEPTION
=
1000
;
...
...
dbms/src/Server/HTTPHandler.cpp
浏览文件 @
97277ed6
...
...
@@ -84,6 +84,7 @@ namespace ErrorCodes
extern
const
int
REQUIRED_PASSWORD
;
extern
const
int
INVALID_SESSION_TIMEOUT
;
extern
const
int
HTTP_LENGTH_REQUIRED
;
}
...
...
@@ -127,6 +128,8 @@ static Poco::Net::HTTPResponse::HTTPStatus exceptionCodeToHTTPStatus(int excepti
else
if
(
exception_code
==
ErrorCodes
::
SOCKET_TIMEOUT
||
exception_code
==
ErrorCodes
::
CANNOT_OPEN_FILE
)
return
HTTPResponse
::
HTTP_SERVICE_UNAVAILABLE
;
else
if
(
exception_code
==
ErrorCodes
::
HTTP_LENGTH_REQUIRED
)
return
HTTPResponse
::
HTTP_LENGTH_REQUIRED
;
return
HTTPResponse
::
HTTP_INTERNAL_SERVER_ERROR
;
}
...
...
@@ -379,14 +382,7 @@ void HTTPHandler::processQuery(
std
::
unique_ptr
<
ReadBuffer
>
in_param
=
std
::
make_unique
<
ReadBufferFromString
>
(
query_param
);
std
::
unique_ptr
<
ReadBuffer
>
in_post_raw
;
/// A grubby workaround for CLICKHOUSE-3333 problem. This condition should detect POST query with empty body.
/// In that case Poco doesn't work properly and returns HTTPInputStream which just listen TCP connection.
/// NOTE: if Poco are updated, this heuristic might not work properly.
if
(
typeid_cast
<
Poco
::
Net
::
HTTPInputStream
*>
(
&
istr
)
==
nullptr
)
in_post_raw
=
std
::
make_unique
<
ReadBufferFromIStream
>
(
istr
);
else
in_post_raw
=
std
::
make_unique
<
ReadBufferFromString
>
(
String
());
// will read empty body.
std
::
unique_ptr
<
ReadBuffer
>
in_post_raw
=
std
::
make_unique
<
ReadBufferFromIStream
>
(
istr
);
/// Request body can be compressed using algorithm specified in the Content-Encoding header.
std
::
unique_ptr
<
ReadBuffer
>
in_post
;
...
...
@@ -567,7 +563,8 @@ void HTTPHandler::trySendExceptionToClient(const std::string & s, int exception_
/// to avoid reading part of the current request body in the next request.
if
(
request
.
getMethod
()
==
Poco
::
Net
::
HTTPRequest
::
HTTP_POST
&&
response
.
getKeepAlive
()
&&
!
request
.
stream
().
eof
())
&&
!
request
.
stream
().
eof
()
&&
exception_code
!=
ErrorCodes
::
HTTP_LENGTH_REQUIRED
)
{
request
.
stream
().
ignore
(
std
::
numeric_limits
<
std
::
streamsize
>::
max
());
}
...
...
@@ -642,6 +639,13 @@ void HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne
HTMLForm
params
(
request
);
with_stacktrace
=
params
.
getParsed
<
bool
>
(
"stacktrace"
,
false
);
/// Workaround. Poco does not detect 411 Length Required case.
if
(
request
.
getMethod
()
==
Poco
::
Net
::
HTTPRequest
::
HTTP_POST
&&
!
request
.
getChunkedTransferEncoding
()
&&
!
request
.
hasContentLength
())
{
throw
Exception
(
"There is neither Transfer-Encoding header nor Content-Length header"
,
ErrorCodes
::
HTTP_LENGTH_REQUIRED
);
}
processQuery
(
request
,
params
,
response
,
used_output
);
LOG_INFO
(
log
,
"Done processing query"
);
}
...
...
dbms/tests/queries/0_stateless/00501_http_head.reference
浏览文件 @
97277ed6
...
...
@@ -10,5 +10,3 @@ Content-Type: text/tab-separated-values; charset=UTF-8
Transfer-Encoding: chunked
Keep-Alive: timeout=3
1
1
dbms/tests/queries/0_stateless/00501_http_head.sh
浏览文件 @
97277ed6
...
...
@@ -3,5 +3,6 @@
(
curl
-s
--head
"
${
CLICKHOUSE_URL
:
=http
://localhost:8123/
}
?query=SELECT%201"
;
curl
-s
--head
"
${
CLICKHOUSE_URL
:
=http
://localhost:8123/
}
?query=select+*+from+system.numbers+limit+1000000"
)
|
grep
-v
"Date:"
curl
-sS
-X
POST
"http://127.0.0.1:8123?query=SELECT+1"
curl
-sS
-X
POST
"http://127.0.0.1:8123?query=SELECT+1"
--data
''
if
[[
`
curl
-sS
-X
POST
-I
"http://127.0.0.1:8123?query=SELECT+1"
|
grep
-c
'411 Length Required'
`
-ne
1
]]
;
then
echo
FAIL
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录