(t *testing.T)
| 281 | } |
| 282 | |
| 283 | func TestBuildHTTPRequest(t *testing.T) { |
| 284 | tests := []struct { |
| 285 | name string |
| 286 | connectRequest *pogs.ConnectRequest |
| 287 | body io.ReadCloser |
| 288 | req *http.Request |
| 289 | }{ |
| 290 | { |
| 291 | name: "check if http.Request is built correctly with content length", |
| 292 | connectRequest: &pogs.ConnectRequest{ |
| 293 | Dest: "http://test.com", |
| 294 | Metadata: []pogs.Metadata{ |
| 295 | { |
| 296 | Key: "HttpHeader:Cf-Cloudflared-Proxy-Connection-Upgrade", |
| 297 | Val: "Websocket", |
| 298 | }, |
| 299 | { |
| 300 | Key: "HttpHeader:Content-Length", |
| 301 | Val: "514", |
| 302 | }, |
| 303 | { |
| 304 | Key: "HttpHeader:Another-Header", |
| 305 | Val: "Misc", |
| 306 | }, |
| 307 | { |
| 308 | Key: "HttpHost", |
| 309 | Val: "cf.host", |
| 310 | }, |
| 311 | { |
| 312 | Key: "HttpMethod", |
| 313 | Val: "get", |
| 314 | }, |
| 315 | }, |
| 316 | }, |
| 317 | req: &http.Request{ |
| 318 | Method: "get", |
| 319 | URL: &url.URL{ |
| 320 | Scheme: "http", |
| 321 | Host: "test.com", |
| 322 | }, |
| 323 | Proto: "HTTP/1.1", |
| 324 | ProtoMajor: 1, |
| 325 | ProtoMinor: 1, |
| 326 | Header: http.Header{ |
| 327 | "Another-Header": []string{"Misc"}, |
| 328 | "Content-Length": []string{"514"}, |
| 329 | }, |
| 330 | ContentLength: 514, |
| 331 | Host: "cf.host", |
| 332 | Body: io.NopCloser(&bytes.Buffer{}), |
| 333 | }, |
| 334 | body: io.NopCloser(&bytes.Buffer{}), |
| 335 | }, |
| 336 | { |
| 337 | name: "if content length isn't part of request headers, then it's not set", |
| 338 | connectRequest: &pogs.ConnectRequest{ |
| 339 | Dest: "http://test.com", |
| 340 | Metadata: []pogs.Metadata{ |
nothing calls this directly
no test coverage detected