| 151 | } |
| 152 | |
| 153 | bool HttpServletResponse::sendHeader(void) |
| 154 | { |
| 155 | if (head_sent_) { |
| 156 | return true; |
| 157 | } |
| 158 | head_sent_ = true; |
| 159 | |
| 160 | acl_assert(header_->is_request() == false); |
| 161 | |
| 162 | char buf[256]; |
| 163 | if (charset_[0] != 0) { |
| 164 | safe_snprintf(buf, sizeof(buf), "%s; charset=%s", |
| 165 | content_type_, charset_); |
| 166 | } else { |
| 167 | safe_snprintf(buf, sizeof(buf), "%s", content_type_); |
| 168 | } |
| 169 | |
| 170 | header_->set_content_type(buf); |
| 171 | |
| 172 | // ��Ȼ���������Ӧͷ�������� gzip ѹ����ʽ�����������˲����� |
| 173 | // gzip ѹ�����ݣ�����Ҫ����Ӧͷ�н�ֹ |
| 174 | if (header_->is_transfer_gzip() && request_) { |
| 175 | bool accept_gzip = false; |
| 176 | std::vector<string> tokens; |
| 177 | request_->getAcceptEncoding(tokens); |
| 178 | std::vector<string>::const_iterator it; |
| 179 | |
| 180 | for (it = tokens.begin(); it != tokens.end(); ++it) { |
| 181 | if ((*it).compare("gzip", false) == 0) { |
| 182 | accept_gzip = true; |
| 183 | break; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (!accept_gzip) { |
| 188 | header_->set_transfer_gzip(false); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | return client_->write_head(*header_); |
| 193 | } |
| 194 | |
| 195 | bool HttpServletResponse::write(const void* data, size_t len) |
| 196 | { |
no test coverage detected