/*
- Copyright (C) 2000-2005 SKYRIX Software AG
+ Copyright (C) 2000-2008 SKYRIX Software AG
This file is part of SOPE.
writeErrorHandler:
if (writeError == 1) {
- if (toApp) NGBufferedDescriptor_free(toApp);
+ if (toApp) {
+ NGBufferedDescriptor_free(toApp);
+ toApp = NULL;
+ }
ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
"socket write error during transfer of HTTP header section");
if (!NGBufferedDescriptor_safeWrite(toApp,
requestBody,
requestContentLength)) {
- if (toApp) NGBufferedDescriptor_free(toApp);
+ if (toApp) {
+ NGBufferedDescriptor_free(toApp);
+ toApp = NULL;
+ }
ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
"couldn't transfer HTTP req body to app server (%i bytes)",
contentLength);
/* read response line */
if (!NGScanResponseLine(toApp, NULL, &statusCode, NULL)) {
- if (toApp) NGBufferedDescriptor_free(toApp);
+ if (toApp) {
+ NGBufferedDescriptor_free(toApp);
+ toApp = NULL;
+ }
ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,
"error during reading of response line ..");
return 500;
}
// read whole response
- if (!NGBufferedDescriptor_safeRead(toApp, buffer, contentLength)) {
- if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; }
- }
+ NGBufferedDescriptor_safeRead(toApp, buffer, contentLength);
- // close connection to app
- if (toApp != NULL) { NGBufferedDescriptor_free(toApp); toApp = NULL; }
-
ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server,
"send response (size=%i)",
contentLength);
int result = 0;
int writeCount = 0;
- do {
- result = NGBufferedDescriptor_read(toApp, buffer, sizeof(buffer));
- if (result > 0) {
- ap_rwrite(buffer, result, r);
- ap_rflush(r);
- writeCount += result;
- }
+ while ((result = NGBufferedDescriptor_read(toApp,
+ buffer,
+ sizeof(buffer))
+ > 0)) {
+ ap_rwrite(buffer, result, r);
+ ap_rflush(r);
+ writeCount += result;
}
- while (result > 0);
if (HEAVY_LOG && (writeCount > 0)) {
ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server,
}
}
}
-
+
+ // close connection to app
+ if (toApp) {
+ NGBufferedDescriptor_free(toApp);
+ toApp = NULL;
+ }
+
return OK;
}