| 46 | } |
| 47 | |
| 48 | void HttpResponse::writeHeaders() |
| 49 | { |
| 50 | Q_ASSERT(sentHeaders==false); |
| 51 | QByteArray buffer; |
| 52 | buffer.append("HTTP/1.1 "); |
| 53 | buffer.append(QByteArray::number(statusCode)); |
| 54 | buffer.append(' '); |
| 55 | buffer.append(statusText); |
| 56 | buffer.append("\r\n"); |
| 57 | foreach(QByteArray name, headers.keys()) |
| 58 | { |
| 59 | buffer.append(name); |
| 60 | buffer.append(": "); |
| 61 | buffer.append(headers.value(name)); |
| 62 | buffer.append("\r\n"); |
| 63 | } |
| 64 | foreach(HttpCookie cookie,cookies.values()) |
| 65 | { |
| 66 | buffer.append("Set-Cookie: "); |
| 67 | buffer.append(cookie.toByteArray()); |
| 68 | buffer.append("\r\n"); |
| 69 | } |
| 70 | buffer.append("\r\n"); |
| 71 | writeToSocket(buffer); |
| 72 | socket->flush(); |
| 73 | sentHeaders=true; |
| 74 | } |
| 75 | |
| 76 | bool HttpResponse::writeToSocket(QByteArray data) |
| 77 | { |