Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
0fa584c2
Commit
0fa584c2
authored
12 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
HTTPClient: fixed max_bodysize when using keep-alive
parent
47a8b919
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/HTTPClient.php
+28
-13
28 additions, 13 deletions
inc/HTTPClient.php
with
28 additions
and
13 deletions
inc/HTTPClient.php
+
28
−
13
View file @
0fa584c2
...
...
@@ -215,6 +215,9 @@ class HTTPClient {
$this
->
start
=
$this
->
_time
();
$this
->
error
=
''
;
$this
->
status
=
0
;
$this
->
status
=
0
;
$this
->
resp_body
=
''
;
$this
->
resp_headers
=
array
();
// don't accept gzip if truncated bodies might occur
if
(
$this
->
max_bodysize
&&
...
...
@@ -440,9 +443,31 @@ class HTTPClient {
$byte
=
$this
->
_readData
(
$socket
,
2
,
'chunk'
);
// read trailing \r\n
}
}
while
(
$chunk_size
&&
!
$abort
);
}
elseif
(
$this
->
max_bodysize
){
// read just over the max_bodysize
$r_body
=
$this
->
_readData
(
$socket
,
$this
->
max_bodysize
+
1
,
'response'
,
true
);
}
elseif
(
isset
(
$this
->
resp_headers
[
'content-length'
])
&&
!
isset
(
$this
->
resp_headers
[
'transfer-encoding'
])){
/* RFC 2616
* If a message is received with both a Transfer-Encoding header field and a Content-Length
* header field, the latter MUST be ignored.
*/
// read up to the content-length or max_bodysize
// for keep alive we need to read the whole message to clean up the socket for the next read
if
(
!
$this
->
keep_alive
&&
$this
->
max_bodysize
&&
$this
->
max_bodysize
<
$this
->
resp_headers
[
'content-length'
]){
$length
=
$this
->
max_bodysize
;
}
else
{
$length
=
$this
->
resp_headers
[
'content-length'
];
}
$r_body
=
$this
->
_readData
(
$socket
,
$length
,
'response (content-length limited)'
,
true
);
}
else
{
// read entire socket
$r_size
=
0
;
while
(
!
feof
(
$socket
))
{
$r_body
.
=
$this
->
_readData
(
$socket
,
4096
,
'response (unlimited)'
,
true
);
}
}
// recheck body size, we might had to read the whole body, so we abort late or trim here
if
(
$this
->
max_bodysize
){
if
(
strlen
(
$r_body
)
>
$this
->
max_bodysize
){
if
(
$this
->
max_bodysize_abort
)
{
throw
new
HTTPClientException
(
'Allowed response size exceeded'
);
...
...
@@ -450,16 +475,6 @@ class HTTPClient {
$this
->
error
=
'Allowed response size exceeded'
;
}
}
}
elseif
(
isset
(
$this
->
resp_headers
[
'content-length'
])
&&
!
isset
(
$this
->
resp_headers
[
'transfer-encoding'
])){
// read up to the content-length
$r_body
=
$this
->
_readData
(
$socket
,
$this
->
resp_headers
[
'content-length'
],
'response'
,
true
);
}
else
{
// read entire socket
$r_size
=
0
;
while
(
!
feof
(
$socket
))
{
$r_body
.
=
$this
->
_readData
(
$socket
,
4096
,
'response'
,
true
);
}
}
}
catch
(
HTTPClientException
$err
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment