(private xhr: XMLHttpRequest)
| 190 | url: string; |
| 191 | |
| 192 | constructor(private xhr: XMLHttpRequest) { |
| 193 | this.status = xhr.status; |
| 194 | this.statusText = xhr.statusText; |
| 195 | this.url = xhr.responseURL; |
| 196 | this.ok = this.status >= 200 && this.status < 300; |
| 197 | this.headers = new Headers(); |
| 198 | |
| 199 | const rawHeaders = xhr.getAllResponseHeaders(); |
| 200 | for (const line of rawHeaders.trim().split(/[\r\n]+/)) { |
| 201 | if (!line) continue; |
| 202 | |
| 203 | const separatorIndex = line.indexOf(":"); |
| 204 | if (separatorIndex < 0) continue; |
| 205 | |
| 206 | this.headers.append(line.slice(0, separatorIndex).trim(), line.slice(separatorIndex + 1).trim()); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | async text(): Promise<string> { |
| 211 | return typeof this.xhr.response === "string" |
nothing calls this directly
no outgoing calls
no test coverage detected