diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-05-09 18:12:28 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-05-09 18:12:28 +0200 |
commit | 05213d6f1d8e946e717dee948bd14b6ef3876827 (patch) | |
tree | c55f16f937e34d9de933dd6ce8cda0f62c2e8bff /plugins/fcgi/fcgi.cpp | |
parent | 91f78915fed4b1a3706c4d08a9b0c2c458cb0a2e (diff) |
Improve socket read handling
Diffstat (limited to 'plugins/fcgi/fcgi.cpp')
-rw-r--r-- | plugins/fcgi/fcgi.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/plugins/fcgi/fcgi.cpp b/plugins/fcgi/fcgi.cpp index bb0a8b4..d19916c 100644 --- a/plugins/fcgi/fcgi.cpp +++ b/plugins/fcgi/fcgi.cpp @@ -407,7 +407,7 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) FCGI_Record stdin_{FCGI_STDIN, id, body}; if (socket->write(stdin_.getBuffer()) != stdin_.getBuffer().size()) std::cerr << "Warning: Not all bytes written 6" << std::endl; - + if (body.size()) { FCGI_Record stdin_end{FCGI_STDIN, id, std::string{}}; if (socket->write(stdin_end.getBuffer()) != stdin_end.getBuffer().size()) @@ -424,15 +424,14 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) std::cerr << "Warning: Not all bytes written 8" << std::endl; #endif - bool ended{false}; std::vector<char> inbuf; - std::vector<char> inbuf_part(1024); + + bool ended{false}; while (!ended) { try { - size_t got {socket->read(inbuf_part)}; - inbuf.insert(inbuf.end(), inbuf_part.begin(), inbuf_part.begin() + got); + socket->read(inbuf); } catch (const fcgi_eof_error&) { - //std::cerr << "FCGI Warning: Early EOF" << std::endl; // seems to be ok here + std::cerr << "FCGI Warning: Early EOF" << std::endl; // seems to be ok here ended = true; //return HttpStatus("500", "FCGI connection: EOF on read", context.SetResponseHeader); } @@ -453,7 +452,7 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) } else throw std::runtime_error("Unhandled FCGI type: "s + std::to_string(r.getType())); } catch (const std::length_error& ex) { - // ignore if not enough data available yet + // ignore FCGI_Record construction if not enough data available for full record yet break; } } |