Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2899d8b8
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2899d8b8
编写于
1月 18, 2012
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7126960: Add property to limit number of request headers to the HTTP Server
Reviewed-by: michaelm
上级
9588c551
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
83 addition
and
69 deletion
+83
-69
src/share/classes/sun/net/httpserver/Request.java
src/share/classes/sun/net/httpserver/Request.java
+7
-0
src/share/classes/sun/net/httpserver/ServerConfig.java
src/share/classes/sun/net/httpserver/ServerConfig.java
+76
-69
未找到文件。
src/share/classes/sun/net/httpserver/Request.java
浏览文件 @
2899d8b8
...
@@ -203,6 +203,13 @@ class Request {
...
@@ -203,6 +203,13 @@ class Request {
v
=
new
String
();
v
=
new
String
();
else
else
v
=
String
.
copyValueOf
(
s
,
keyend
,
len
-
keyend
);
v
=
String
.
copyValueOf
(
s
,
keyend
,
len
-
keyend
);
if
(
hdrs
.
size
()
>=
ServerConfig
.
getMaxReqHeaders
())
{
throw
new
IOException
(
"Maximum number of request headers ("
+
"sun.net.httpserver.maxReqHeaders) exceeded, "
+
ServerConfig
.
getMaxReqHeaders
()
+
"."
);
}
hdrs
.
add
(
k
,
v
);
hdrs
.
add
(
k
,
v
);
len
=
0
;
len
=
0
;
}
}
...
...
src/share/classes/sun/net/httpserver/ServerConfig.java
浏览文件 @
2899d8b8
/*
/*
* Copyright (c) 2005, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
package
sun.net.httpserver
;
package
sun.net.httpserver
;
import
com.sun.net.httpserver.*
;
import
com.sun.net.httpserver.spi.*
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
java.security.PrivilegedAction
;
import
java.security.PrivilegedAction
;
...
@@ -37,74 +35,75 @@ import java.security.PrivilegedAction;
...
@@ -37,74 +35,75 @@ import java.security.PrivilegedAction;
class
ServerConfig
{
class
ServerConfig
{
static
int
clockTick
;
private
static
final
int
DEFAULT_CLOCK_TICK
=
10000
;
// 10 sec.
static
final
int
DEFAULT_CLOCK_TICK
=
10000
;
// 10 sec.
/* These values must be a reasonable multiple of clockTick */
/* These values must be a reasonable multiple of clockTick */
static
final
long
DEFAULT_IDLE_INTERVAL
=
30
;
// 5 min
private
static
final
long
DEFAULT_IDLE_INTERVAL
=
30
;
// 5 min
static
final
int
DEFAULT_MAX_IDLE_CONNECTIONS
=
200
;
private
static
final
int
DEFAULT_MAX_IDLE_CONNECTIONS
=
200
;
static
final
long
DEFAULT_MAX_REQ_TIME
=
-
1
;
// default: forever
private
static
final
long
DEFAULT_MAX_REQ_TIME
=
-
1
;
// default: forever
static
final
long
DEFAULT_MAX_RSP_TIME
=
-
1
;
// default: forever
private
static
final
long
DEFAULT_MAX_RSP_TIME
=
-
1
;
// default: forever
static
final
long
DEFAULT_TIMER_MILLIS
=
1000
;
private
static
final
long
DEFAULT_TIMER_MILLIS
=
1000
;
private
static
final
int
DEFAULT_MAX_REQ_HEADERS
=
200
;
private
static
final
long
DEFAULT_DRAIN_AMOUNT
=
64
*
1024
;
private
static
int
clockTick
;
private
static
long
idleInterval
;
// The maximum number of bytes to drain from an inputstream
private
static
long
drainAmount
;
private
static
int
maxIdleConnections
;
// The maximum number of request headers allowable
private
static
int
maxReqHeaders
;
// max time a request or response is allowed to take
private
static
long
maxReqTime
;
private
static
long
maxRspTime
;
private
static
long
timerMillis
;
private
static
boolean
debug
;
static
final
long
DEFAULT_DRAIN_AMOUNT
=
64
*
1024
;
// the value of the TCP_NODELAY socket-level option
private
static
boolean
noDelay
;
static
long
idleInterval
;
static
{
static
long
drainAmount
;
// max # of bytes to drain from an inputstream
java
.
security
.
AccessController
.
doPrivileged
(
static
int
maxIdleConnections
;
new
PrivilegedAction
<
Void
>()
{
@Override
public
Void
run
()
{
idleInterval
=
Long
.
getLong
(
"sun.net.httpserver.idleInterval"
,
DEFAULT_IDLE_INTERVAL
)
*
1000
;
// max time a request or response is allowed to take
clockTick
=
Integer
.
getInteger
(
"sun.net.httpserver.clockTick"
,
static
long
maxReqTime
;
DEFAULT_CLOCK_TICK
);
static
long
maxRspTime
;
static
long
timerMillis
;
static
boolean
debug
=
false
;
static
{
maxIdleConnections
=
Integer
.
getInteger
(
"sun.net.httpserver.maxIdleConnections"
,
DEFAULT_MAX_IDLE_CONNECTIONS
);
idleInterval
=
((
Long
)
java
.
security
.
AccessController
.
doPrivileged
(
drainAmount
=
Long
.
getLong
(
"sun.net.httpserver.drainAmount"
,
new
sun
.
security
.
action
.
GetLongAction
(
DEFAULT_DRAIN_AMOUNT
);
"sun.net.httpserver.idleInterval"
,
DEFAULT_IDLE_INTERVAL
))).
longValue
()
*
1000
;
clockTick
=
((
Integer
)
java
.
security
.
AccessController
.
doPrivileged
(
maxReqHeaders
=
Integer
.
getInteger
(
new
sun
.
security
.
action
.
GetIntegerAction
(
"sun.net.httpserver.maxReqHeaders"
,
"sun.net.httpserver.clockTick"
,
DEFAULT_MAX_REQ_HEADERS
);
DEFAULT_CLOCK_TICK
))).
intValue
();
maxIdleConnections
=
((
Integer
)
java
.
security
.
AccessController
.
doPrivileged
(
maxReqTime
=
Long
.
getLong
(
"sun.net.httpserver.maxReqTime"
,
new
sun
.
security
.
action
.
GetIntegerAction
(
DEFAULT_MAX_REQ_TIME
);
"sun.net.httpserver.maxIdleConnections"
,
DEFAULT_MAX_IDLE_CONNECTIONS
))).
intValue
();
drainAmount
=
((
Long
)
java
.
security
.
AccessController
.
doPrivileged
(
maxRspTime
=
Long
.
getLong
(
"sun.net.httpserver.maxRspTime"
,
new
sun
.
security
.
action
.
GetLongAction
(
DEFAULT_MAX_RSP_TIME
);
"sun.net.httpserver.drainAmount"
,
DEFAULT_DRAIN_AMOUNT
))).
longValue
();
maxReqTime
=
((
Long
)
java
.
security
.
AccessController
.
doPrivileged
(
timerMillis
=
Long
.
getLong
(
"sun.net.httpserver.timerMillis"
,
new
sun
.
security
.
action
.
GetLongAction
(
DEFAULT_TIMER_MILLIS
);
"sun.net.httpserver.maxReqTime"
,
DEFAULT_MAX_REQ_TIME
))).
longValue
();
maxRspTime
=
((
Long
)
java
.
security
.
AccessController
.
doPrivileged
(
debug
=
Boolean
.
getBoolean
(
"sun.net.httpserver.debug"
);
new
sun
.
security
.
action
.
GetLongAction
(
"sun.net.httpserver.maxRspTime"
,
DEFAULT_MAX_RSP_TIME
))).
longValue
();
timerMillis
=
((
Long
)
java
.
security
.
AccessController
.
doPrivileged
(
noDelay
=
Boolean
.
getBoolean
(
"sun.net.httpserver.nodelay"
);
new
sun
.
security
.
action
.
GetLongAction
(
"sun.net.httpserver.timerMillis"
,
DEFAULT_TIMER_MILLIS
))).
longValue
();
debug
=
((
Boolean
)
java
.
security
.
AccessController
.
doPrivileged
(
return
null
;
new
sun
.
security
.
action
.
GetBooleanAction
(
}
"sun.net.httpserver.debug"
))).
booleanValue
(
);
}
);
}
}
static
void
checkLegacyProperties
(
final
Logger
logger
)
{
static
void
checkLegacyProperties
(
final
Logger
logger
)
{
// legacy properties that are no longer used
// legacy properties that are no longer used
// print a warning to logger if they are set.
// print a warning to logger if they are set.
...
@@ -141,35 +140,43 @@ class ServerConfig {
...
@@ -141,35 +140,43 @@ class ServerConfig {
);
);
}
}
static
boolean
debugEnabled
()
{
static
boolean
debugEnabled
()
{
return
debug
;
return
debug
;
}
}
static
long
getIdleInterval
()
{
static
long
getIdleInterval
()
{
return
idleInterval
;
return
idleInterval
;
}
}
static
int
getClockTick
()
{
static
int
getClockTick
()
{
return
clockTick
;
return
clockTick
;
}
}
static
int
getMaxIdleConnections
()
{
static
int
getMaxIdleConnections
()
{
return
maxIdleConnections
;
return
maxIdleConnections
;
}
}
static
long
getDrainAmount
()
{
static
long
getDrainAmount
()
{
return
drainAmount
;
return
drainAmount
;
}
}
static
long
getMaxReqTime
()
{
static
int
getMaxReqHeaders
()
{
return
maxReqHeaders
;
}
static
long
getMaxReqTime
()
{
return
maxReqTime
;
return
maxReqTime
;
}
}
static
long
getMaxRspTime
()
{
static
long
getMaxRspTime
()
{
return
maxRspTime
;
return
maxRspTime
;
}
}
static
long
getTimerMillis
()
{
static
long
getTimerMillis
()
{
return
timerMillis
;
return
timerMillis
;
}
}
static
boolean
noDelay
()
{
return
noDelay
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录