Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
02bb977d
Commit
02bb977d
authored
Sep 20, 2001
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed aliases like upper=string.join by native string method calls.
This increases performances by about 6 % (using ab).
parent
0b62c54d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
28 deletions
+18
-28
ZServer/HTTPServer.py
ZServer/HTTPServer.py
+9
-14
lib/python/ZServer/HTTPServer.py
lib/python/ZServer/HTTPServer.py
+9
-14
No files found.
ZServer/HTTPServer.py
View file @
02bb977d
...
@@ -215,11 +215,11 @@ class zhttp_handler:
...
@@ -215,11 +215,11 @@ class zhttp_handler:
def
handle_request
(
self
,
request
):
def
handle_request
(
self
,
request
):
self
.
hits
.
increment
()
self
.
hits
.
increment
()
DebugLogger
.
log
(
'B'
,
id
(
request
),
'%s %s'
%
(
string
.
upper
(
request
.
command
),
request
.
uri
))
DebugLogger
.
log
(
'B'
,
id
(
request
),
'%s %s'
%
(
request
.
command
.
upper
(
),
request
.
uri
))
size
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
size
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
if
size
and
size
!=
'0'
:
if
size
and
size
!=
'0'
:
size
=
string
.
atoi
(
size
)
size
=
int
(
size
)
zhttp_collector
(
self
,
request
,
size
)
zhttp_collector
(
self
,
request
,
size
)
else
:
else
:
sin
=
StringIO
()
sin
=
StringIO
()
...
@@ -227,11 +227,6 @@ class zhttp_handler:
...
@@ -227,11 +227,6 @@ class zhttp_handler:
def
get_environment
(
self
,
request
,
def
get_environment
(
self
,
request
,
# These are strictly performance hackery...
# These are strictly performance hackery...
split
=
string
.
split
,
strip
=
string
.
strip
,
join
=
string
.
join
,
upper
=
string
.
upper
,
lower
=
string
.
lower
,
h2ehas
=
header2env
.
has_key
,
h2ehas
=
header2env
.
has_key
,
h2eget
=
header2env
.
get
,
h2eget
=
header2env
.
get
,
workdir
=
os
.
getcwd
(),
workdir
=
os
.
getcwd
(),
...
@@ -250,7 +245,7 @@ class zhttp_handler:
...
@@ -250,7 +245,7 @@ class zhttp_handler:
server
=
request
.
channel
.
server
server
=
request
.
channel
.
server
env
=
{}
env
=
{}
env
[
'REQUEST_METHOD'
]
=
upper
(
request
.
command
)
env
[
'REQUEST_METHOD'
]
=
request
.
command
.
upper
(
)
env
[
'SERVER_PORT'
]
=
str
(
server
.
port
)
env
[
'SERVER_PORT'
]
=
str
(
server
.
port
)
env
[
'SERVER_NAME'
]
=
server
.
server_name
env
[
'SERVER_NAME'
]
=
server
.
server_name
env
[
'SERVER_SOFTWARE'
]
=
server
.
SERVER_IDENT
env
[
'SERVER_SOFTWARE'
]
=
server
.
SERVER_IDENT
...
@@ -262,7 +257,7 @@ class zhttp_handler:
...
@@ -262,7 +257,7 @@ class zhttp_handler:
else
:
else
:
env
[
'SCRIPT_NAME'
]
=
self
.
uri_base
env
[
'SCRIPT_NAME'
]
=
self
.
uri_base
try
:
try
:
path_info
=
split
(
path
,
self
.
uri_base
[
1
:],
1
)[
1
]
path_info
=
path
.
split
(
self
.
uri_base
[
1
:],
1
)[
1
]
except
:
except
:
path_info
=
''
path_info
=
''
env
[
'PATH_INFO'
]
=
path_info
env
[
'PATH_INFO'
]
=
path_info
...
@@ -284,13 +279,13 @@ class zhttp_handler:
...
@@ -284,13 +279,13 @@ class zhttp_handler:
env_has
=
env
.
has_key
env_has
=
env
.
has_key
for
header
in
request
.
header
:
for
header
in
request
.
header
:
key
,
value
=
split
(
header
,
":"
,
1
)
key
,
value
=
header
.
split
(
":"
,
1
)
key
=
lower
(
key
)
key
=
key
.
lower
(
)
value
=
strip
(
value
)
value
=
value
.
strip
(
)
if
h2ehas
(
key
)
and
value
:
if
h2ehas
(
key
)
and
value
:
env
[
h2eget
(
key
)]
=
value
env
[
h2eget
(
key
)]
=
value
else
:
else
:
key
=
'HTTP_%s'
%
upper
(
join
(
split
(
key
,
"-"
),
"_"
)
)
key
=
'HTTP_%s'
%
(
"_"
.
join
(
key
.
split
(
"-"
))).
upper
(
)
if
value
and
not
env_has
(
key
):
if
value
and
not
env_has
(
key
):
env
[
key
]
=
value
env
[
key
]
=
value
env
.
update
(
self
.
env_override
)
env
.
update
(
self
.
env_override
)
...
@@ -301,7 +296,7 @@ class zhttp_handler:
...
@@ -301,7 +296,7 @@ class zhttp_handler:
s
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
s
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
if
s
:
if
s
:
s
=
string
.
atoi
(
s
)
s
=
int
(
s
)
else
:
else
:
s
=
0
s
=
0
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
...
...
lib/python/ZServer/HTTPServer.py
View file @
02bb977d
...
@@ -215,11 +215,11 @@ class zhttp_handler:
...
@@ -215,11 +215,11 @@ class zhttp_handler:
def
handle_request
(
self
,
request
):
def
handle_request
(
self
,
request
):
self
.
hits
.
increment
()
self
.
hits
.
increment
()
DebugLogger
.
log
(
'B'
,
id
(
request
),
'%s %s'
%
(
string
.
upper
(
request
.
command
),
request
.
uri
))
DebugLogger
.
log
(
'B'
,
id
(
request
),
'%s %s'
%
(
request
.
command
.
upper
(
),
request
.
uri
))
size
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
size
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
if
size
and
size
!=
'0'
:
if
size
and
size
!=
'0'
:
size
=
string
.
atoi
(
size
)
size
=
int
(
size
)
zhttp_collector
(
self
,
request
,
size
)
zhttp_collector
(
self
,
request
,
size
)
else
:
else
:
sin
=
StringIO
()
sin
=
StringIO
()
...
@@ -227,11 +227,6 @@ class zhttp_handler:
...
@@ -227,11 +227,6 @@ class zhttp_handler:
def
get_environment
(
self
,
request
,
def
get_environment
(
self
,
request
,
# These are strictly performance hackery...
# These are strictly performance hackery...
split
=
string
.
split
,
strip
=
string
.
strip
,
join
=
string
.
join
,
upper
=
string
.
upper
,
lower
=
string
.
lower
,
h2ehas
=
header2env
.
has_key
,
h2ehas
=
header2env
.
has_key
,
h2eget
=
header2env
.
get
,
h2eget
=
header2env
.
get
,
workdir
=
os
.
getcwd
(),
workdir
=
os
.
getcwd
(),
...
@@ -250,7 +245,7 @@ class zhttp_handler:
...
@@ -250,7 +245,7 @@ class zhttp_handler:
server
=
request
.
channel
.
server
server
=
request
.
channel
.
server
env
=
{}
env
=
{}
env
[
'REQUEST_METHOD'
]
=
upper
(
request
.
command
)
env
[
'REQUEST_METHOD'
]
=
request
.
command
.
upper
(
)
env
[
'SERVER_PORT'
]
=
str
(
server
.
port
)
env
[
'SERVER_PORT'
]
=
str
(
server
.
port
)
env
[
'SERVER_NAME'
]
=
server
.
server_name
env
[
'SERVER_NAME'
]
=
server
.
server_name
env
[
'SERVER_SOFTWARE'
]
=
server
.
SERVER_IDENT
env
[
'SERVER_SOFTWARE'
]
=
server
.
SERVER_IDENT
...
@@ -262,7 +257,7 @@ class zhttp_handler:
...
@@ -262,7 +257,7 @@ class zhttp_handler:
else
:
else
:
env
[
'SCRIPT_NAME'
]
=
self
.
uri_base
env
[
'SCRIPT_NAME'
]
=
self
.
uri_base
try
:
try
:
path_info
=
split
(
path
,
self
.
uri_base
[
1
:],
1
)[
1
]
path_info
=
path
.
split
(
self
.
uri_base
[
1
:],
1
)[
1
]
except
:
except
:
path_info
=
''
path_info
=
''
env
[
'PATH_INFO'
]
=
path_info
env
[
'PATH_INFO'
]
=
path_info
...
@@ -284,13 +279,13 @@ class zhttp_handler:
...
@@ -284,13 +279,13 @@ class zhttp_handler:
env_has
=
env
.
has_key
env_has
=
env
.
has_key
for
header
in
request
.
header
:
for
header
in
request
.
header
:
key
,
value
=
split
(
header
,
":"
,
1
)
key
,
value
=
header
.
split
(
":"
,
1
)
key
=
lower
(
key
)
key
=
key
.
lower
(
)
value
=
strip
(
value
)
value
=
value
.
strip
(
)
if
h2ehas
(
key
)
and
value
:
if
h2ehas
(
key
)
and
value
:
env
[
h2eget
(
key
)]
=
value
env
[
h2eget
(
key
)]
=
value
else
:
else
:
key
=
'HTTP_%s'
%
upper
(
join
(
split
(
key
,
"-"
),
"_"
)
)
key
=
'HTTP_%s'
%
(
"_"
.
join
(
key
.
split
(
"-"
))).
upper
(
)
if
value
and
not
env_has
(
key
):
if
value
and
not
env_has
(
key
):
env
[
key
]
=
value
env
[
key
]
=
value
env
.
update
(
self
.
env_override
)
env
.
update
(
self
.
env_override
)
...
@@ -301,7 +296,7 @@ class zhttp_handler:
...
@@ -301,7 +296,7 @@ class zhttp_handler:
s
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
s
=
get_header
(
CONTENT_LENGTH
,
request
.
header
)
if
s
:
if
s
:
s
=
string
.
atoi
(
s
)
s
=
int
(
s
)
else
:
else
:
s
=
0
s
=
0
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment