FACT++  1.0
void ConnectionLid::HandleRead ( const boost::system::error_code &  err,
size_t  bytes_received 
)
inlineprivate

Definition at line 174 of file lidctrl.cc.

References Error(), and str.

Referenced by StartReadReport().

175  {
176  // Do not schedule a new read if the connection failed.
177  if (bytes_received==0 || err)
178  {
179  if (err==ba::error::eof)
180  {
181  //Warn("Connection closed by remote host.");
182  ProcessAnswer();
183  PostClose(false);
184  return;
185  }
186 
187  // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
188  // 125: Operation canceled
189  if (err && err!=ba::error::eof && // Connection closed by remote host
190  err!=ba::error::basic_errors::not_connected && // Connection closed by remote host
191  err!=ba::error::basic_errors::operation_aborted) // Connection closed by us
192  {
193  ostringstream str;
194  str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
195  Error(str);
196  }
197  PostClose(err!=ba::error::basic_errors::operation_aborted);
198 
199  fRdfData = "";
200  return;
201  }
202 
203  fRdfData += string(fArray.data(), bytes_received);
204 
205  //cout << "." << flush;
206 
207  // Does the message contain a header?
208  const size_t p1 = fRdfData.find("\r\n\r\n");
209  if (p1!=string::npos)
210  {
211  // Does the answer also contain the body?
212  const size_t p2 = fRdfData.find("\r\n\r\n", p1+4);
213  if (p2!=string::npos)
214  {
215  ProcessAnswer();
216  }
217  }
218 
219  // Go on reading until the web-server closes the connection
220  StartReadReport();
221  }
boost::array< char, 4096 > fArray
Definition: lidctrl.cc:89
void PostClose(bool restart=true)
Definition: Connection.cc:125
void StartReadReport()
Definition: lidctrl.cc:225
string fRdfData
Definition: lidctrl.cc:87
char str[80]
Definition: test_client.c:7
void ProcessAnswer()
Definition: lidctrl.cc:103
std::string URL() const
Definition: Connection.h:151
int Error(const std::string &str)
Definition: MessageImp.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function: