$response = false; try { $request = $transport->parseRequest($_SERVER['REQUEST_URI'] === '' ? '/' : $_SERVER['REQUEST_URI']); $request->validateHeaders(); } catch (Exception $e) { file_put_contents($logDir . 'transport_parse_error.txt', (string) $e); $response = new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_400); } // We already may have caused some error response, so that we do not need to // handle the request any more if ($response === false) { // Log parsed request file_put_contents($logDir . 'request.txt', "<?php\n\nreturn " . var_export($request, true) . "\n?>"); // Try to handle given request in backend, and log failures try { $response = $backend->performRequest($request); } catch (Exception $e) { file_put_contents($logDir . 'backend_error.txt', (string) $e); $response = new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_500); } } // Log handled response file_put_contents($logDir . 'response.txt', "<?php\n\nreturn " . var_export($response, true) . "\n?>"); // Try to serialize response back, log on error try { $transport->handleResponse($response); } catch (Exception $e) { file_put_contents($logDir . 'transport_serialize_error.txt', (string) $e); die('Error handling response: ' . $e->getMessage()); } // Log actual response