| 103 | } |
| 104 | |
| 105 | void HttpResponse::addStatusLine(const String& line) |
| 106 | { |
| 107 | const char* SP = " "; |
| 108 | int idx = 0; |
| 109 | int begin = 0; |
| 110 | String statusCode; |
| 111 | |
| 112 | /* Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF */ |
| 113 | |
| 114 | /* HTTP-Version */ |
| 115 | idx = line.indexOf(SP); |
| 116 | |
| 117 | /* Malformed status line? */ |
| 118 | if (0 > idx) |
| 119 | { |
| 120 | m_httpVersion.clear(); |
| 121 | m_statusCode = 0U; |
| 122 | m_reasonPhrase.clear(); |
| 123 | } |
| 124 | else |
| 125 | { |
| 126 | m_httpVersion = line.substring(begin, idx); |
| 127 | |
| 128 | /* Overstep all spaces */ |
| 129 | while (('\0' != line[idx]) && (' ' == line[idx])) |
| 130 | { |
| 131 | ++idx; |
| 132 | } |
| 133 | begin = idx; |
| 134 | |
| 135 | /* Status-Code */ |
| 136 | idx = line.indexOf(SP, begin); |
| 137 | |
| 138 | /* Malformed status code? */ |
| 139 | if (0 > idx) |
| 140 | { |
| 141 | m_httpVersion.clear(); |
| 142 | m_statusCode = 0U; |
| 143 | m_reasonPhrase.clear(); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | statusCode = line.substring(begin, idx); |
| 148 | m_statusCode = statusCode.toInt(); |
| 149 | |
| 150 | /* Overstep all spaces */ |
| 151 | while (('\0' != line[idx]) && (' ' == line[idx])) |
| 152 | { |
| 153 | ++idx; |
| 154 | } |
| 155 | begin = idx; |
| 156 | |
| 157 | /* Reason-Phrase */ |
| 158 | m_reasonPhrase = line.substring(begin); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 |
no test coverage detected