Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/imap
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-06-23 17:41:06 +0400
committerIgor Sysoev <igor@sysoev.ru>2005-06-23 17:41:06 +0400
commit85ef94ba857237882c7e68dea87a1dbc68a38fe7 (patch)
tree1bc05e18adaabc75f91f1c7b34c7358e60b0efdc /src/imap
parent2e87bb645af1d3152c9961d49ca093d4cbfe630d (diff)
nginx-0.1.37-RELEASE importrelease-0.1.37
*) Change: now the "\n" is added to the end of the "nginx.pid" file. *) Bugfix: the responses may be transferred not completely, if many parts or the big parts were included by SSI. *) Bugfix: if all backends had returned the 404 reponse and the "http_404" parameter of the "proxy_next_upstream" or "fastcgi_next_upstream" directives was used, then nginx started to request all backends again.
Diffstat (limited to 'src/imap')
-rw-r--r--src/imap/ngx_imap.h1
-rw-r--r--src/imap/ngx_imap_auth_http_module.c60
-rw-r--r--src/imap/ngx_imap_handler.c15
3 files changed, 61 insertions, 15 deletions
diff --git a/src/imap/ngx_imap.h b/src/imap/ngx_imap.h
index 38f449891..5ba390055 100644
--- a/src/imap/ngx_imap.h
+++ b/src/imap/ngx_imap.h
@@ -136,6 +136,7 @@ typedef struct {
void ngx_imap_init_connection(ngx_connection_t *c);
void ngx_imap_close_connection(ngx_connection_t *c);
+void ngx_imap_session_internal_server_error(ngx_imap_session_t *s);
ngx_int_t ngx_pop3_parse_command(ngx_imap_session_t *s);
diff --git a/src/imap/ngx_imap_auth_http_module.c b/src/imap/ngx_imap_auth_http_module.c
index 7e6c44b23..fa984b855 100644
--- a/src/imap/ngx_imap_auth_http_module.c
+++ b/src/imap/ngx_imap_auth_http_module.c
@@ -23,6 +23,7 @@ typedef struct {
typedef struct {
ngx_buf_t *request;
+ ngx_buf_t *response;
ngx_peer_connection_t peer;
} ngx_imap_auth_http_ctx_t;
@@ -91,7 +92,7 @@ ngx_imap_auth_http_init(ngx_imap_session_t *s)
ctx = ngx_pcalloc(s->connection->pool, sizeof(ngx_imap_auth_http_ctx_t));
if (ctx == NULL) {
- ngx_imap_close_connection(s->connection);
+ ngx_imap_session_internal_server_error(s);
return;
}
@@ -99,7 +100,7 @@ ngx_imap_auth_http_init(ngx_imap_session_t *s)
ctx->request = ngx_imap_auth_http_create_request(s, ahcf);
if (ctx->request == NULL) {
- ngx_imap_close_connection(s->connection);
+ ngx_imap_session_internal_server_error(s);
return;
}
@@ -112,7 +113,7 @@ ngx_imap_auth_http_init(ngx_imap_session_t *s)
rc = ngx_event_connect_peer(&ctx->peer);
if (rc == NGX_ERROR) {
- ngx_imap_close_connection(s->connection);
+ ngx_imap_session_internal_server_error(s);
return;
}
@@ -153,8 +154,8 @@ ngx_imap_auth_http_write_handler(ngx_event_t *wev)
if (wev->timedout) {
ngx_log_error(NGX_LOG_ERR, wev->log, NGX_ETIMEDOUT,
"auth http server timed out");
- ngx_imap_close_connection(ctx->peer.connection);
- ngx_imap_close_connection(s->connection);
+ ngx_close_connection(ctx->peer.connection);
+ ngx_imap_session_internal_server_error(s);
return;
}
@@ -163,8 +164,8 @@ ngx_imap_auth_http_write_handler(ngx_event_t *wev)
n = ngx_send(c, ctx->request->pos, size);
if (n == NGX_ERROR) {
- ngx_imap_close_connection(ctx->peer.connection);
- ngx_imap_close_connection(s->connection);
+ ngx_close_connection(ctx->peer.connection);
+ ngx_imap_session_internal_server_error(s);
return;
}
@@ -192,23 +193,52 @@ ngx_imap_auth_http_write_handler(ngx_event_t *wev)
static void
ngx_imap_auth_http_read_handler(ngx_event_t *rev)
{
+ ssize_t n, size;
ngx_peers_t *peers;
ngx_connection_t *c;
ngx_imap_session_t *s;
-#if 0
ngx_imap_auth_http_ctx_t *ctx;
-#endif
c = rev->data;
s = c->data;
-#if 0
- ctx = ngx_imap_get_module_ctx(s, ngx_imap_auth_http_module);
-#endif
-
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0,
"imap auth http read handler");
+ ctx = ngx_imap_get_module_ctx(s, ngx_imap_auth_http_module);
+
+ if (rev->timedout) {
+ ngx_log_error(NGX_LOG_ERR, rev->log, NGX_ETIMEDOUT,
+ "auth http server timed out");
+ ngx_close_connection(ctx->peer.connection);
+ ngx_imap_session_internal_server_error(s);
+ return;
+ }
+
+ if (ctx->response == NULL) {
+ ctx->response = ngx_create_temp_buf(s->connection->pool, 1024);
+ if (ctx->response == NULL) {
+ ngx_close_connection(ctx->peer.connection);
+ ngx_imap_session_internal_server_error(s);
+ return;
+ }
+ }
+
+ size = ctx->response->last - ctx->response->pos;
+
+ n = ngx_recv(c, ctx->response->pos, size);
+
+ if (n == NGX_ERROR || n == 0) {
+ ngx_close_connection(ctx->peer.connection);
+ ngx_imap_session_internal_server_error(s);
+ return;
+ }
+
+
+
+
+
+
peers = NULL;
ngx_imap_proxy_init(s, peers);
@@ -231,8 +261,8 @@ ngx_imap_auth_http_block_read(ngx_event_t *rev)
ctx = ngx_imap_get_module_ctx(s, ngx_imap_auth_http_module);
- ngx_imap_close_connection(ctx->peer.connection);
- ngx_imap_close_connection(s->connection);
+ ngx_close_connection(ctx->peer.connection);
+ ngx_imap_session_internal_server_error(s);
}
}
diff --git a/src/imap/ngx_imap_handler.c b/src/imap/ngx_imap_handler.c
index be2c9d1c5..680bf20d0 100644
--- a/src/imap/ngx_imap_handler.c
+++ b/src/imap/ngx_imap_handler.c
@@ -24,6 +24,11 @@ static ngx_str_t greetings[] = {
ngx_string("* OK " NGINX_VER " ready" CRLF)
};
+static ngx_str_t internal_server_errors[] = {
+ ngx_string("-ERR internal server error" CRLF),
+ ngx_string("* BAD internal server error" CRLF),
+};
+
static u_char pop3_ok[] = "+OK" CRLF;
static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF;
@@ -342,6 +347,16 @@ ngx_imap_close_session(ngx_imap_session_t *s)
void
+ngx_imap_session_internal_server_error(ngx_imap_session_t *s)
+{
+ (void) ngx_send(s->connection, internal_server_errors[s->protocol].data,
+ internal_server_errors[s->protocol].len);
+
+ ngx_imap_close_connection(s->connection);
+}
+
+
+void
ngx_imap_close_connection(ngx_connection_t *c)
{
ngx_pool_t *pool;