comparison src/http/modules/proxy/ngx_http_event_proxy_handler.c @ 73:4534060fde92

nginx-0.0.1-2003-04-10-19:08:54 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 10 Apr 2003 15:08:54 +0000
parents 66de3f065886
children 17ab1af8c3dd
comparison
equal deleted inserted replaced
72:66de3f065886 73:4534060fde92
820 820
821 if (!p->accel && p->headers_in.date) { 821 if (!p->accel && p->headers_in.date) {
822 r->headers_out.date = p->headers_in.date; 822 r->headers_out.date = p->headers_in.date;
823 } 823 }
824 824
825 /* TODO: look "Content-Length" */
826 p->block_size = p->lcf->block_size;
827
825 r->headers_out.status = p->status; 828 r->headers_out.status = p->status;
826 829
827 /* STUB */ r->header_only = 1;
828
829 rc = ngx_http_send_header(r); 830 rc = ngx_http_send_header(r);
831
832 /* STUB */
833 p->header_in->type |= NGX_HUNK_LAST;
834 rc = ngx_http_output_filter(r, p->header_in);
835 ngx_http_proxy_finalize_request(p, NGX_OK);
830 836
831 /* STUB */ return NGX_DONE; 837 /* STUB */ return NGX_DONE;
832 } 838 }
833 839
834 if (rc > NGX_OK) { 840 if (rc > NGX_OK) {
1022 1028
1023 #if 0 1029 #if 0
1024 1030
1025 static int ngx_http_proxy_read_upstream_body(ngx_event_t *rev) 1031 static int ngx_http_proxy_read_upstream_body(ngx_event_t *rev)
1026 { 1032 {
1033 ngx_hunk_t *h;
1034 ngx_chain_t *chain, ce;
1035 ngx_connection_t *c;
1036 ngx_http_request_t *r;
1037 ngx_http_proxy_ctx_t *p;
1038
1039 c = (ngx_connection_t *) rev->data;
1040 r = (ngx_http_request_t *) c->data;
1041 p = (ngx_http_proxy_ctx_t *)
1042 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
1043
1044 ce.next = NULL;
1045
1027 do { 1046 do {
1028 if (free) { 1047
1029 buf = get 1048 #if (USE_KQUEUE)
1030 else if (kqueue and eof) { 1049
1031 buf = &buf; 1050 if (ev->eof && ev->available == 0) {
1032 size = 0; 1051 break;
1033 else if (p->cur_hunks < p->nhunks) 1052 }
1034 palloc 1053
1035 p->cur_hunks++; 1054 #elif (HAVE_KQUEUE)
1036 else 1055
1037 write first 1056 if (ngx_event_type == NGX_HAVE_KQUEUE_EVENT
1038 add file hunk to out 1057 && ev->eof && ev->available == 0)
1039 } 1058 {
1040 1059 break;
1041 n = ngx_event_recv(c, buf, size); 1060 }
1061
1062 #endif
1063
1064 if (p->free_hunks) {
1065 chain = p->free_hunks;
1066
1067 } else if (p->allocated < p->lcf->max_block_size) {
1068 ngx_test_null(h,
1069 ngx_create_temp_hunk(r->pool, p->block_size, 50, 50),
1070 NGX_ERROR);
1071
1072 p->allocated += p->block_size;
1073 ce.hunk = h;
1074 chain = &ce;
1075
1076 } else {
1077 if (p->temp_fd == NGX_INVALID_FILE) {
1078 rc = ngx_create_temp_file(p->temp_file, r->cachable);
1079
1080 if (rc != NGX_OK) {
1081 return rc;
1082 }
1083
1084 if (p->lcf->temp_file_warn) {
1085 ngx_log_error(NGX_LOG_WARN, p->log, 0,
1086 "an upstream response is buffered "
1087 "to a temporary file");
1088 }
1089 }
1090
1091 n = ngx_write_chain_to_file(p->temp_file, p->in_hunks,
1092 p->temp_offset);
1093
1094 if (n == NGX_ERROR) {
1095 return NGX_ERROR;
1096 }
1097
1098 ngx_test_null(h, ngx_pcalloc(r->pool, sizeof(ngx_hunk_t)),
1099 NGX_ERROR);
1100
1101 h->type = NGX_HUNK_FILE
1102 |NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP|NGX_HUNK_RECYCLED;
1103
1104 h->file_pos = p->temp_offset;
1105 p->temp_offset += n;
1106 h->file_last = p->temp_offset;
1107
1108 h->file->fd = p->temp_file.fd;
1109 h->file->log = p->log;
1110
1111 h->pos = p->in_hunks->hunk->pos;
1112 h->last = p->in_hunks->hunk->last;
1113 h->start = p->in_hunks->hunk->start;
1114 h->end = p->in_hunks->hunk->end;
1115 h->pre_start = p->in_hunks->hunk->pre_start;
1116 h->post_end = p->in_hunks->hunk->post_end;
1117
1118 ngx_add_hunk_to_chain(p->last_out_hunk, h, r->pool, NGX_ERROR);
1119
1120 ce.hunk = p->in_hunks->next;
1121 p->in_hunks = p->in_hunks->next;
1122 chain = &ce;
1123 }
1124
1125 n = ngx_recv_chain(c, chain);
1126
1127 h->last += n;
1128 left = hunk->end - hunk->last;
1042 1129
1043 } while (n > 0 && left == 0); 1130 } while (n > 0 && left == 0);
1044 1131
1045 if (out && p->request->connection->write->ready) { 1132 if (p->out_hunks && p->request->connection->write->ready) {
1046 ngx_http_proxy_write_upstream_body(p->request->connection->write); 1133 ngx_http_proxy_write_upstream_body(p->request->connection->write);
1047 } 1134 }
1048 } 1135 }
1049 1136
1050 1137