@@ -184,7 +184,7 @@ StaticFileHandler::StaticFileHandler(const std::string& path,
184184 out_off_(0 ),
185185 file_size_(0 ),
186186 fd_(-1 ),
187- eof_ (false )
187+ done_ (false )
188188
189189{
190190 struct ResolveResult r;
@@ -207,7 +207,7 @@ StaticFileHandler::StaticFileHandler(const std::string& path,
207207 HttpResponse::kStatusOk , " text/html; charset=UTF-8" , html, req_);
208208
209209 out_buf_ = res_.to_string ();
210- eof_ = true ;
210+ done_ = true ;
211211 return ;
212212 }
213213
@@ -245,11 +245,16 @@ size_t StaticFileHandler::read_output(char* buf, size_t n)
245245 }
246246 }
247247 if (fd_ == -1 ) // safeguard
248+ {
249+ done_ = true ;
248250 return copied;
251+ }
252+
249253 ssize_t bytes = read (fd_, buf + copied, n - copied);
250254 if (bytes == 0 ) {
251255 close (fd_);
252256 fd_ = -1 ;
257+ done_ = true ;
253258 return copied;
254259 }
255260 if (bytes < 0 ) {
@@ -271,7 +276,7 @@ void StaticFileHandler::set_error(const HttpResponse::Status code)
271276{
272277 res_ = HttpResponse::make_error (code, rc_.shared .error_pages , req_);
273278 out_buf_ = res_.to_string ();
274- eof_ = true ;
279+ done_ = true ;
275280}
276281
277282void StaticFileHandler::set_redirect (const HttpResponse::Status code,
@@ -280,5 +285,5 @@ void StaticFileHandler::set_redirect(const HttpResponse::Status code,
280285 res_ = HttpResponse::make_response_headers_only (code, " " , 0 , req_);
281286 res_.location = redirect_path;
282287 out_buf_ = res_.to_string ();
283- eof_ = true ;
288+ done_ = true ;
284289}
0 commit comments