comparison src/imap/ngx_imap_auth_http_module.c @ 527:7fa11e5c6e96 release-0.1.38

nginx-0.1.38-RELEASE import *) Feature: the "limit_rate" directive is supported in in proxy and FastCGI mode. *) Feature: the "X-Accel-Limit-Rate" response header line is supported in proxy and FastCGI mode. *) Feature: the "break" directive. *) Feature: the "log_not_found" directive. *) Bugfix: the response status code was not changed when request was redirected by the ""X-Accel-Redirect" header line. *) Bugfix: the variables set by the "set" directive could not be used in SSI. *) Bugfix: the segmentation fault may occurred if the SSI page has more than one remote subrequest. *) Bugfix: nginx treated the backend response as invalid if the status line in the header was transferred in two packets; the bug had appeared in 0.1.29. *) Feature: the "ssi_types" directive. *) Feature: the "autoindex_exact_size" directive. *) Bugfix: the ngx_http_autoindex_module did not support the long file names in UTF-8. *) Feature: the IMAP/POP3 proxy.
author Igor Sysoev <igor@sysoev.ru>
date Fri, 08 Jul 2005 14:34:20 +0000
parents 09b42134ac0c
children 371c1cee100d
comparison
equal deleted inserted replaced
526:e31ce4d8b8e6 527:7fa11e5c6e96
10 #include <ngx_event_connect.h> 10 #include <ngx_event_connect.h>
11 #include <ngx_imap.h> 11 #include <ngx_imap.h>
12 12
13 13
14 typedef struct { 14 typedef struct {
15 ngx_peers_t *peers; 15 ngx_peers_t *peers;
16 16
17 ngx_msec_t timeout; 17 ngx_msec_t timeout;
18 18
19 ngx_str_t host_header; 19 ngx_str_t host_header;
20 ngx_str_t uri; 20 ngx_str_t uri;
21 } ngx_imap_auth_http_conf_t; 21 } ngx_imap_auth_http_conf_t;
22 22
23 23
24 typedef struct { 24 typedef struct ngx_imap_auth_http_ctx_s ngx_imap_auth_http_ctx_t;
25 ngx_buf_t *request; 25
26 ngx_buf_t *response; 26 typedef void (*ngx_imap_auth_http_handler_pt)(ngx_imap_session_t *s,
27 ngx_peer_connection_t peer; 27 ngx_imap_auth_http_ctx_t *ctx);
28 } ngx_imap_auth_http_ctx_t; 28
29 struct ngx_imap_auth_http_ctx_s {
30 ngx_buf_t *request;
31 ngx_buf_t *response;
32 ngx_peer_connection_t peer;
33
34 ngx_imap_auth_http_handler_pt handler;
35
36 ngx_uint_t state;
37 ngx_uint_t hash; /* no needed ? */
38
39 u_char *header_name_start;
40 u_char *header_name_end;
41 u_char *header_start;
42 u_char *header_end;
43
44 ngx_str_t addr;
45 ngx_str_t port;
46 ngx_str_t err;
47
48 ngx_msec_t sleep;
49
50 ngx_peers_t *peers;
51 };
29 52
30 53
31 static void ngx_imap_auth_http_write_handler(ngx_event_t *wev); 54 static void ngx_imap_auth_http_write_handler(ngx_event_t *wev);
32 static void ngx_imap_auth_http_read_handler(ngx_event_t *rev); 55 static void ngx_imap_auth_http_read_handler(ngx_event_t *rev);
56 static void ngx_imap_auth_http_ignore_status_line(ngx_imap_session_t *s,
57 ngx_imap_auth_http_ctx_t *ctx);
58 static void ngx_imap_auth_http_process_headers(ngx_imap_session_t *s,
59 ngx_imap_auth_http_ctx_t *ctx);
60 static void ngx_imap_auth_sleep_handler(ngx_event_t *rev);
61 static ngx_int_t ngx_imap_auth_http_parse_header_line(ngx_imap_session_t *s,
62 ngx_imap_auth_http_ctx_t *ctx);
33 static void ngx_imap_auth_http_block_read(ngx_event_t *rev); 63 static void ngx_imap_auth_http_block_read(ngx_event_t *rev);
34 static void ngx_imap_auth_http_dummy_handler(ngx_event_t *ev); 64 static void ngx_imap_auth_http_dummy_handler(ngx_event_t *ev);
35 static ngx_buf_t *ngx_imap_auth_http_create_request(ngx_imap_session_t *s, 65 static ngx_buf_t *ngx_imap_auth_http_create_request(ngx_imap_session_t *s,
36 ngx_imap_auth_http_conf_t *ahcf); 66 ngx_imap_auth_http_conf_t *ahcf);
37 67
122 152
123 s->connection->read->handler = ngx_imap_auth_http_block_read; 153 s->connection->read->handler = ngx_imap_auth_http_block_read;
124 ctx->peer.connection->read->handler = ngx_imap_auth_http_read_handler; 154 ctx->peer.connection->read->handler = ngx_imap_auth_http_read_handler;
125 ctx->peer.connection->write->handler = ngx_imap_auth_http_write_handler; 155 ctx->peer.connection->write->handler = ngx_imap_auth_http_write_handler;
126 156
157 ctx->handler = ngx_imap_auth_http_ignore_status_line;
158
127 if (rc == NGX_OK) { 159 if (rc == NGX_OK) {
128 ngx_imap_auth_http_write_handler(ctx->peer.connection->write); 160 ngx_imap_auth_http_write_handler(ctx->peer.connection->write);
129 return; 161 return;
130 } 162 }
131 163
192 224
193 static void 225 static void
194 ngx_imap_auth_http_read_handler(ngx_event_t *rev) 226 ngx_imap_auth_http_read_handler(ngx_event_t *rev)
195 { 227 {
196 ssize_t n, size; 228 ssize_t n, size;
197 ngx_peers_t *peers;
198 ngx_connection_t *c; 229 ngx_connection_t *c;
199 ngx_imap_session_t *s; 230 ngx_imap_session_t *s;
200 ngx_imap_auth_http_ctx_t *ctx; 231 ngx_imap_auth_http_ctx_t *ctx;
201 232
202 c = rev->data; 233 c = rev->data;
222 ngx_imap_session_internal_server_error(s); 253 ngx_imap_session_internal_server_error(s);
223 return; 254 return;
224 } 255 }
225 } 256 }
226 257
227 size = ctx->response->last - ctx->response->pos; 258 size = ctx->response->end - ctx->response->last;
228 259
229 n = ngx_recv(c, ctx->response->pos, size); 260 n = ngx_recv(c, ctx->response->pos, size);
230 261
231 if (n == NGX_ERROR || n == 0) { 262 if (n > 0) {
263 ctx->response->last += n;
264
265 ctx->handler(s, ctx);
266 return;
267 }
268
269 if (n == NGX_AGAIN) {
270 return;
271 }
272
273 ngx_close_connection(ctx->peer.connection);
274 ngx_imap_session_internal_server_error(s);
275 }
276
277
278 static void
279 ngx_imap_auth_http_ignore_status_line(ngx_imap_session_t *s,
280 ngx_imap_auth_http_ctx_t *ctx)
281 {
282 u_char *p, ch;
283 enum {
284 sw_start = 0,
285 sw_H,
286 sw_HT,
287 sw_HTT,
288 sw_HTTP,
289 sw_skip,
290 sw_almost_done
291 } state;
292
293 ngx_log_debug0(NGX_LOG_DEBUG_IMAP, s->connection->log, 0,
294 "imap auth http process status line");
295
296 state = ctx->state;
297
298 for (p = ctx->response->pos; p < ctx->response->last; p++) {
299 ch = *p;
300
301 switch (state) {
302
303 /* "HTTP/" */
304 case sw_start:
305 if (ch == 'H') {
306 state = sw_H;
307 break;
308 }
309 goto next;
310
311 case sw_H:
312 if (ch == 'T') {
313 state = sw_HT;
314 break;
315 }
316 goto next;
317
318 case sw_HT:
319 if (ch == 'T') {
320 state = sw_HTT;
321 break;
322 }
323 goto next;
324
325 case sw_HTT:
326 if (ch == 'P') {
327 state = sw_HTTP;
328 break;
329 }
330 goto next;
331
332 case sw_HTTP:
333 if (ch == '/') {
334 state = sw_skip;
335 break;
336 }
337 goto next;
338
339 /* any text until end of line */
340 case sw_skip:
341 switch (ch) {
342 case CR:
343 state = sw_almost_done;
344
345 break;
346 case LF:
347 goto done;
348 }
349 break;
350
351 /* end of status line */
352 case sw_almost_done:
353 if (ch == LF) {
354 goto done;
355 }
356
357 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
358 "auth http server sent invalid response");
359 ngx_close_connection(ctx->peer.connection);
360 ngx_imap_session_internal_server_error(s);
361 return;
362 }
363 }
364
365 ctx->response->pos = p;
366 ctx->state = state;
367
368 return;
369
370 next:
371
372 p = ctx->response->start - 1;
373
374 done:
375
376 ctx->response->pos = p + 1;
377 ctx->state = 0;
378 ctx->handler = ngx_imap_auth_http_process_headers;
379 ctx->handler(s, ctx);
380 }
381
382
383 static void
384 ngx_imap_auth_http_process_headers(ngx_imap_session_t *s,
385 ngx_imap_auth_http_ctx_t *ctx)
386 {
387 u_char *p;
388 size_t len, size;
389 ngx_int_t rc, port, n;
390 struct sockaddr_in *sin;
391
392 ngx_log_debug0(NGX_LOG_DEBUG_IMAP, s->connection->log, 0,
393 "imap auth http process headers");
394
395 for ( ;; ) {
396 rc = ngx_imap_auth_http_parse_header_line(s, ctx);
397
398 if (rc == NGX_OK) {
399
400 #if (NGX_DEBUG)
401 {
402 ngx_str_t key, value;
403
404 key.len = ctx->header_name_end - ctx->header_name_start;
405 key.data = ctx->header_name_start;
406 value.len = ctx->header_end - ctx->header_start;
407 value.data = ctx->header_start;
408
409 ngx_log_debug2(NGX_LOG_DEBUG_IMAP, s->connection->log, 0,
410 "auth http header: \"%V: %V\"",
411 &key, &value);
412 }
413 #endif
414
415 len = ctx->header_name_end - ctx->header_name_start;
416
417 if (len == sizeof("Auth-Status") - 1
418 && ngx_strncasecmp(ctx->header_name_start, "Auth-Status",
419 sizeof("Auth-Status") - 1) == 0)
420 {
421 len = ctx->header_end - ctx->header_start;
422
423 if (len == 2
424 && ctx->header_start[0] == 'O'
425 && ctx->header_start[1] == 'K')
426 {
427 continue;
428 }
429
430 if (s->protocol == NGX_IMAP_POP3_PROTOCOL) {
431 size = sizeof("-ERR") - 1 + len + sizeof(CRLF) - 1;
432
433 } else {
434 size = s->tag.len + sizeof("NO") - 1 + len
435 + sizeof(CRLF) - 1;
436 }
437
438 p = ngx_pcalloc(s->connection->pool, size);
439 if (p == NULL) {
440 ngx_imap_session_internal_server_error(s);
441 return;
442 }
443
444 ctx->err.data = p;
445
446 if (s->protocol == NGX_IMAP_POP3_PROTOCOL) {
447 *p++ = '-'; *p++ = 'E'; *p++ = 'R'; *p++ = 'R';
448
449 } else {
450 p = ngx_cpymem(p, s->tag.data, s->tag.len);
451 *p++ = 'N'; *p++ = 'O';
452 }
453
454 *p++ = ' ';
455 p = ngx_cpymem(p, ctx->header_start, len);
456 *p++ = CR; *p++ = LF;
457
458 ctx->err.len = p - ctx->err.data;
459
460 continue;
461 }
462
463 if (len == sizeof("Auth-Server") - 1
464 && ngx_strncasecmp(ctx->header_name_start, "Auth-Server",
465 sizeof("Auth-Server") - 1) == 0)
466 {
467 ctx->addr.len = ctx->header_end - ctx->header_start;
468 ctx->addr.data = ctx->header_start;
469
470 continue;
471 }
472
473 if (len == sizeof("Auth-Port") - 1
474 && ngx_strncasecmp(ctx->header_name_start, "Auth-Port",
475 sizeof("Auth-Port") - 1) == 0)
476 {
477 ctx->port.len = ctx->header_end - ctx->header_start;
478 ctx->port.data = ctx->header_start;
479
480 continue;
481 }
482
483 if (len == sizeof("Auth-User") - 1
484 && ngx_strncasecmp(ctx->header_name_start, "Auth-User",
485 sizeof("Auth-User") - 1) == 0)
486 {
487 s->login.len = ctx->header_end - ctx->header_start;
488 s->login.data = ctx->header_start;
489
490 continue;
491 }
492
493 if (len == sizeof("Auth-Wait") - 1
494 && ngx_strncasecmp(ctx->header_name_start, "Auth-Wait",
495 sizeof("Auth-Wait") - 1) == 0)
496 {
497 n = ngx_atoi(ctx->header_start,
498 ctx->header_end - ctx->header_start);
499
500 if (n != NGX_ERROR) {
501 ctx->sleep = n;
502 }
503
504 continue;
505 }
506
507 /* ignore other headers */
508
509 continue;
510 }
511
512 if (rc == NGX_DONE) {
513 ngx_log_debug0(NGX_LOG_DEBUG_IMAP, s->connection->log, 0,
514 "auth http header done");
515
516 ngx_close_connection(ctx->peer.connection);
517
518 if (ctx->err.len) {
519 (void) ngx_send(s->connection, ctx->err.data, ctx->err.len);
520
521 if (ctx->sleep == 0) {
522 ngx_imap_close_connection(s->connection);
523 return;
524 }
525
526 ngx_add_timer(s->connection->read, ctx->sleep * 1000);
527
528 s->connection->read->handler = ngx_imap_auth_sleep_handler;
529
530 return;
531 }
532
533 if (ctx->addr.len == 0 || ctx->port.len == 0) {
534 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
535 "auth http server did not send server or port");
536 ngx_imap_session_internal_server_error(s);
537 return;
538 }
539
540 ctx->peers = ngx_pcalloc(s->connection->pool, sizeof(ngx_peers_t));
541 if (ctx->peers == NULL) {
542 ngx_imap_session_internal_server_error(s);
543 return;
544 }
545
546 sin = ngx_pcalloc(s->connection->pool, sizeof(struct sockaddr_in));
547 if (sin == NULL) {
548 ngx_imap_session_internal_server_error(s);
549 return;
550 }
551
552 sin->sin_family = AF_INET;
553
554 port = ngx_atoi(ctx->port.data, ctx->port.len);
555 if (port == NGX_ERROR || port < 1 || port > 65536) {
556 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
557 "auth http server sent invalid server "
558 "port:\"%V\"", &ctx->port);
559 ngx_imap_session_internal_server_error(s);
560 return;
561 }
562
563 sin->sin_port = htons((in_port_t) port);
564
565 ctx->addr.data[ctx->addr.len] = '\0';
566 sin->sin_addr.s_addr = inet_addr((char *) ctx->addr.data);
567 if (sin->sin_addr.s_addr == INADDR_NONE) {
568 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
569 "auth http server sent invalid server "
570 "address:\"%V\"", &ctx->addr);
571 ngx_imap_session_internal_server_error(s);
572 return;
573 }
574
575 ctx->peers->number = 1;
576
577 ctx->peers->peer[0].sockaddr = (struct sockaddr *) sin;
578 ctx->peers->peer[0].socklen = sizeof(struct sockaddr_in);
579
580 len = ctx->addr.len + 1 + ctx->port.len;
581
582 ctx->peers->peer[0].name.len = len;
583
584 ctx->peers->peer[0].name.data = ngx_palloc(s->connection->pool,
585 len);
586 if (ctx->peers->peer[0].name.data == NULL) {
587 ngx_imap_session_internal_server_error(s);
588 return;
589 }
590
591 len = ctx->addr.len;
592
593 ngx_memcpy(ctx->peers->peer[0].name.data, ctx->addr.data, len);
594
595 ctx->peers->peer[0].name.data[len++] = ':';
596
597 ngx_memcpy(ctx->peers->peer[0].name.data + len,
598 ctx->port.data, ctx->port.len);
599
600 ctx->peers->peer[0].uri_separator = "";
601
602 ngx_imap_proxy_init(s, ctx->peers);
603
604 return;
605 }
606
607 if (rc == NGX_AGAIN ) {
608 return;
609 }
610
611 /* rc == NGX_ERROR */
612
613 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
614 "auth http server sent invalid header in response");
232 ngx_close_connection(ctx->peer.connection); 615 ngx_close_connection(ctx->peer.connection);
233 ngx_imap_session_internal_server_error(s); 616 ngx_imap_session_internal_server_error(s);
617
234 return; 618 return;
235 } 619 }
236 620 }
237 621
238 622
239 623 static void
240 624 ngx_imap_auth_sleep_handler(ngx_event_t *rev)
241 625 {
242 peers = NULL; 626 ngx_connection_t *c;
243 627 ngx_imap_session_t *s;
244 ngx_imap_proxy_init(s, peers); 628
629 ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap auth sleep handler");
630
631 c = rev->data;
632 s = c->data;
633
634 if (rev->timedout) {
635
636 rev->timedout = 0;
637
638 if (s->protocol == NGX_IMAP_POP3_PROTOCOL) {
639 s->imap_state = ngx_pop3_start;
640 s->connection->read->handler = ngx_pop3_auth_state;
641
642 } else {
643 s->imap_state = ngx_imap_start;
644 s->connection->read->handler = ngx_imap_auth_state;
645 }
646
647 if (rev->ready) {
648 s->connection->read->handler(rev);
649 return;
650 }
651
652 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
653 ngx_imap_close_connection(s->connection);
654 }
655
656 return;
657 }
658
659 if (rev->active) {
660 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
661 ngx_imap_close_connection(s->connection);
662 }
663 }
664 }
665
666
667 static ngx_int_t
668 ngx_imap_auth_http_parse_header_line(ngx_imap_session_t *s,
669 ngx_imap_auth_http_ctx_t *ctx)
670 {
671 u_char c, ch, *p;
672 ngx_uint_t hash;
673 enum {
674 sw_start = 0,
675 sw_name,
676 sw_space_before_value,
677 sw_value,
678 sw_space_after_value,
679 sw_almost_done,
680 sw_header_almost_done
681 } state;
682
683 state = ctx->state;
684 hash = ctx->hash;
685
686 for (p = ctx->response->pos; p < ctx->response->last; p++) {
687 ch = *p;
688
689 switch (state) {
690
691 /* first char */
692 case sw_start:
693
694 switch (ch) {
695 case CR:
696 ctx->header_end = p;
697 state = sw_header_almost_done;
698 break;
699 case LF:
700 ctx->header_end = p;
701 goto header_done;
702 default:
703 state = sw_name;
704 ctx->header_name_start = p;
705
706 c = (u_char) (ch | 0x20);
707 if (c >= 'a' && c <= 'z') {
708 hash = c;
709 break;
710 }
711
712 if (ch >= '0' && ch <= '9') {
713 hash = ch;
714 break;
715 }
716
717 return NGX_ERROR;
718 }
719 break;
720
721 /* header name */
722 case sw_name:
723 c = (u_char) (ch | 0x20);
724 if (c >= 'a' && c <= 'z') {
725 hash += c;
726 break;
727 }
728
729 if (ch == ':') {
730 ctx->header_name_end = p;
731 state = sw_space_before_value;
732 break;
733 }
734
735 if (ch == '-') {
736 hash += ch;
737 break;
738 }
739
740 if (ch >= '0' && ch <= '9') {
741 hash += ch;
742 break;
743 }
744
745 if (ch == CR) {
746 ctx->header_name_end = p;
747 ctx->header_start = p;
748 ctx->header_end = p;
749 state = sw_almost_done;
750 break;
751 }
752
753 if (ch == LF) {
754 ctx->header_name_end = p;
755 ctx->header_start = p;
756 ctx->header_end = p;
757 goto done;
758 }
759
760 return NGX_ERROR;
761
762 /* space* before header value */
763 case sw_space_before_value:
764 switch (ch) {
765 case ' ':
766 break;
767 case CR:
768 ctx->header_start = p;
769 ctx->header_end = p;
770 state = sw_almost_done;
771 break;
772 case LF:
773 ctx->header_start = p;
774 ctx->header_end = p;
775 goto done;
776 default:
777 ctx->header_start = p;
778 state = sw_value;
779 break;
780 }
781 break;
782
783 /* header value */
784 case sw_value:
785 switch (ch) {
786 case ' ':
787 ctx->header_end = p;
788 state = sw_space_after_value;
789 break;
790 case CR:
791 ctx->header_end = p;
792 state = sw_almost_done;
793 break;
794 case LF:
795 ctx->header_end = p;
796 goto done;
797 }
798 break;
799
800 /* space* before end of header line */
801 case sw_space_after_value:
802 switch (ch) {
803 case ' ':
804 break;
805 case CR:
806 state = sw_almost_done;
807 break;
808 case LF:
809 goto done;
810 default:
811 state = sw_value;
812 break;
813 }
814 break;
815
816 /* end of header line */
817 case sw_almost_done:
818 switch (ch) {
819 case LF:
820 goto done;
821 default:
822 return NGX_ERROR;
823 }
824
825 /* end of header */
826 case sw_header_almost_done:
827 switch (ch) {
828 case LF:
829 goto header_done;
830 default:
831 return NGX_ERROR;
832 }
833 }
834 }
835
836 ctx->response->pos = p;
837 ctx->state = state;
838 ctx->hash = hash;
839
840 return NGX_AGAIN;
841
842 done:
843
844 ctx->response->pos = p + 1;
845 ctx->state = sw_start;
846 ctx->hash = hash;
847
848 return NGX_OK;
849
850 header_done:
851
852 ctx->response->pos = p + 1;
853 ctx->state = sw_start;
854
855 return NGX_DONE;
245 } 856 }
246 857
247 858
248 static void 859 static void
249 ngx_imap_auth_http_block_read(ngx_event_t *rev) 860 ngx_imap_auth_http_block_read(ngx_event_t *rev)
286 + sizeof("Host: ") - 1 + ahcf->host_header.len + sizeof(CRLF) - 1 897 + sizeof("Host: ") - 1 + ahcf->host_header.len + sizeof(CRLF) - 1
287 + sizeof("Auth-Method: plain" CRLF) - 1 898 + sizeof("Auth-Method: plain" CRLF) - 1
288 + sizeof("Auth-User: ") - 1 + s->login.len + sizeof(CRLF) - 1 899 + sizeof("Auth-User: ") - 1 + s->login.len + sizeof(CRLF) - 1
289 + sizeof("Auth-Pass: ") - 1 + s->passwd.len + sizeof(CRLF) - 1 900 + sizeof("Auth-Pass: ") - 1 + s->passwd.len + sizeof(CRLF) - 1
290 + sizeof("Auth-Protocol: imap" CRLF) - 1 901 + sizeof("Auth-Protocol: imap" CRLF) - 1
902 + sizeof("Auth-Login-Attempt: ") - 1 + NGX_INT_T_LEN
903 + sizeof(CRLF) - 1
291 + sizeof("Client-IP: ") - 1 + s->connection->addr_text.len 904 + sizeof("Client-IP: ") - 1 + s->connection->addr_text.len
292 + sizeof(CRLF) - 1 905 + sizeof(CRLF) - 1
293 + sizeof(CRLF) - 1; 906 + sizeof(CRLF) - 1;
294 907
295 b = ngx_create_temp_buf(s->connection->pool, len); 908 b = ngx_create_temp_buf(s->connection->pool, len);
322 sizeof("Auth-Protocol: ") - 1); 935 sizeof("Auth-Protocol: ") - 1);
323 b->last = ngx_cpymem(b->last, ngx_imap_auth_http_protocol[s->protocol], 936 b->last = ngx_cpymem(b->last, ngx_imap_auth_http_protocol[s->protocol],
324 sizeof("imap") - 1); 937 sizeof("imap") - 1);
325 *b->last++ = CR; *b->last++ = LF; 938 *b->last++ = CR; *b->last++ = LF;
326 939
940 b->last = ngx_sprintf(b->last, "Auth-Login-Attempt: %ui" CRLF,
941 s->login_attempt);
942
327 b->last = ngx_cpymem(b->last, "Client-IP: ", sizeof("Client-IP: ") - 1); 943 b->last = ngx_cpymem(b->last, "Client-IP: ", sizeof("Client-IP: ") - 1);
328 b->last = ngx_cpymem(b->last, s->connection->addr_text.data, 944 b->last = ngx_cpymem(b->last, s->connection->addr_text.data,
329 s->connection->addr_text.len); 945 s->connection->addr_text.len);
330 *b->last++ = CR; *b->last++ = LF; 946 *b->last++ = CR; *b->last++ = LF;
331 947
336 { 952 {
337 ngx_str_t l; 953 ngx_str_t l;
338 954
339 l.len = b->last - b->pos; 955 l.len = b->last - b->pos;
340 l.data = b->pos; 956 l.data = b->pos;
341 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, s->connection->log, 0, 957 ngx_log_debug1(NGX_LOG_DEBUG_IMAP, s->connection->log, 0,
342 "imap auth http header:\n\"%V\"", &l); 958 "imap auth http header:\n\"%V\"", &l);
343 } 959 }
344 #endif 960 #endif
345 961
346 return b; 962 return b;
438 if (ahcf->peers == NULL) { 1054 if (ahcf->peers == NULL) {
439 return NGX_CONF_ERROR; 1055 return NGX_CONF_ERROR;
440 } 1056 }
441 1057
442 for (i = 0; i < ahcf->peers->number; i++) { 1058 for (i = 0; i < ahcf->peers->number; i++) {
443 ahcf->peers->peer[i].uri_separator = ":"; 1059 ahcf->peers->peer[i].uri_separator = "";
444 } 1060 }
445 1061
446 ahcf->host_header = inet_upstream.host_header; 1062 ahcf->host_header = inet_upstream.host_header;
447 ahcf->uri = inet_upstream.uri; 1063 ahcf->uri = inet_upstream.uri;
448 } 1064 }