Skip to content

Commit

Permalink
Merge pull request #664 from bbockelm/close_simple_reads
Browse files Browse the repository at this point in the history
Close file handle for simple HTTP reads.
  • Loading branch information
ffurano committed Mar 16, 2018
2 parents c33e585 + 7820587 commit f486090
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/XrdHttp/XrdHttpReq.cc
Expand Up @@ -302,6 +302,7 @@ int XrdHttpReq::parseRWOp(char *str) {
len_ok += len;
rwOps_split.push_back(nfo);
}
length += len_ok;


}
Expand Down Expand Up @@ -984,7 +985,7 @@ int XrdHttpReq::ProcessHTTPReq() {
{

if ( ((reqstate == 3) && (rwOps.size() > 1)) ||
(writtenbytes >= filesize) ) {
(writtenbytes >= length) ) {

// Close() if this was a readv or we have finished, otherwise read the next chunk

Expand Down Expand Up @@ -1677,6 +1678,12 @@ int XrdHttpReq::PostProcessHTTPReq(bool final_) {
&filesize,
&fileflags,
&filemodtime);

// We will default the response size specified by the headers; if that
// wasn't given, use the file size.
if (!length) {
length = filesize;
}
}
else
TRACEI(REQ, "Can't find the stat information for '" << resource << "' Internal error?");
Expand Down Expand Up @@ -1716,6 +1723,12 @@ int XrdHttpReq::PostProcessHTTPReq(bool final_) {
&filesize,
&fileflags,
&filemodtime);

// As above: if the client specified a response size, we use that.
// Otherwise, utilize the filesize
if (!length) {
length = filesize;
}
}
else
TRACEI(ALL, "GET returned no STAT information. Internal error?");
Expand Down
2 changes: 1 addition & 1 deletion src/XrdHttp/XrdHttpReq.hh
Expand Up @@ -187,7 +187,7 @@ public:
std::vector<ReadWriteOp> rwOps_split;

bool keepalive;
long long length;
long long length; // Total size from client for PUT; total length of response TO client for GET.
int depth;
bool sendcontinue;

Expand Down

0 comments on commit f486090

Please sign in to comment.