| 176 | } |
| 177 | |
| 178 | int ReadHTTPMessage(basic_istream<char>& stream, map<string, string>& mapHeadersRet, string& strMessageRet, |
| 179 | int nProto) { |
| 180 | mapHeadersRet.clear(); |
| 181 | strMessageRet = ""; |
| 182 | |
| 183 | // Read header |
| 184 | int nLen = ReadHTTPHeaders(stream, mapHeadersRet); |
| 185 | if (nLen < 0 || nLen > (int)MAX_SIZE) |
| 186 | return HTTP_INTERNAL_SERVER_ERROR; |
| 187 | |
| 188 | // Read message |
| 189 | if (nLen > 0) { |
| 190 | vector<char> vch(nLen); |
| 191 | stream.read(&vch[0], nLen); |
| 192 | strMessageRet = string(vch.begin(), vch.end()); |
| 193 | } |
| 194 | |
| 195 | string sConHdr = mapHeadersRet["connection"]; |
| 196 | |
| 197 | if ((sConHdr != "close") && (sConHdr != "keep-alive")) { |
| 198 | if (nProto >= 1) |
| 199 | mapHeadersRet["connection"] = "keep-alive"; |
| 200 | else |
| 201 | mapHeadersRet["connection"] = "close"; |
| 202 | } |
| 203 | |
| 204 | return HTTP_OK; |
| 205 | } |
| 206 | |
| 207 | // |
| 208 | // JSON-RPC protocol. Coin speaks version 1.0 for maximum compatibility, |