MCPcopy Create free account
hub / github.com/acl-dev/acl / build_response

Method build_response

lib_acl_cpp/src/http/http_header.cpp:1214–1292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1212}
1213
1214bool http_header::build_response(string& out) const
1215{
1216 out.clear();
1217
1218 if (fixed_) {
1219 build_common(out);
1220 out << "\r\n";
1221 return true;
1222 }
1223
1224 if (status_ > 0) {
1225 if (cgi_mode_) {
1226 out.format("STATUS: %d\r\n", status_);
1227 } else {
1228 if (version_[0] != 0) {
1229 out << "HTTP/" << version_ << "\r\n";
1230 } else {
1231 out = "HTTP/1.1 ";
1232 }
1233 out << status_ << " " << http_status(status_) << "\r\n";
1234
1235 time_t now = time(NULL);
1236 char buf[64];
1237 date_format(buf, sizeof(buf), now);
1238 out << "Date: " << buf << "\r\n";
1239 //out << "Server: acl\r\n";
1240 }
1241 }
1242
1243 build_common(out);
1244
1245 if (!cookies_.empty()) {
1246 std::list<HttpCookie*>::const_iterator it = cookies_.begin();
1247 for (; it != cookies_.end(); ++it) {
1248 out.format_append("Set-Cookie: %s=%s",
1249 (*it)->getName(), (*it)->getValue());
1250 const std::list<HTTP_PARAM*>& params = (*it)->getParams();
1251 std::list<HTTP_PARAM*>::const_iterator cit = params.begin();
1252 for (; cit != params.end(); ++ cit) {
1253 out.format_append("; %s=%s",
1254 (*cit)->name, (*cit)->value);
1255 }
1256 out << "\r\n";
1257 }
1258 }
1259
1260 if (upgrade_ && *upgrade_) {
1261 if (ws_sec_key_ && *ws_sec_key_) {
1262 append_accept_key(ws_sec_key_, out);
1263 }
1264
1265 out << "\r\n";
1266 return true;
1267 }
1268
1269 // ���ӷֶ���Ӧ�ֶ�
1270 if (range_from_ >= 0
1271 && range_to_ >= range_from_ && range_total_ > 0) {

Callers 9

on_http_res_hdrMethod · 0.80
on_http_res_hdrMethod · 0.80
handle_requestFunction · 0.80
mainFunction · 0.80
on_http_res_hdrMethod · 0.80
on_http_res_hdrMethod · 0.80
on_http_res_hdrMethod · 0.80
write_headMethod · 0.80
transfer_fileMethod · 0.80

Calls 8

http_statusFunction · 0.85
beginMethod · 0.80
clearMethod · 0.45
formatMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
getNameMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected