tracex: prepare HTTP code for future refactoring (#778)
The main issue I see inside tracex at the moment is that we construct the HTTP measurement from separate events. This is fragile because we cannot be sure that these events belong to the same round trip. (Currently, they _are_ part of the same round trip, but this is a fragile assumption and it would be much more robust to dispose of it.) To prepare for emitting a single event, it's imperative to have two distinct fields for HTTP request and response headers, which is the main contribution in this commit. Then, we have a bunch of smaller changes including: 1. correctly naming 'response' the DNS response (instead of 'reply') 2. ensure we always use pointer receivers Reference issue: https://github.com/ooni/probe/issues/2121
This commit is contained in:
parent
c740be987b
commit
66fd1569b8
9 changed files with 69 additions and 68 deletions
|
|
@ -153,16 +153,16 @@ func newRequestList(begin time.Time, events []Event) []RequestEntry {
|
|||
case *EventHTTPRequestMetadata:
|
||||
entry.Request.Headers = make(map[string]MaybeBinaryValue)
|
||||
httpAddHeaders(
|
||||
ev.HTTPHeaders, &entry.Request.HeadersList, &entry.Request.Headers)
|
||||
ev.HTTPRequestHeaders, &entry.Request.HeadersList, &entry.Request.Headers)
|
||||
entry.Request.Method = ev.HTTPMethod
|
||||
entry.Request.URL = ev.HTTPURL
|
||||
entry.Request.Transport = ev.Transport
|
||||
case *EventHTTPResponseMetadata:
|
||||
entry.Response.Headers = make(map[string]MaybeBinaryValue)
|
||||
httpAddHeaders(
|
||||
ev.HTTPHeaders, &entry.Response.HeadersList, &entry.Response.Headers)
|
||||
ev.HTTPResponseHeaders, &entry.Response.HeadersList, &entry.Response.Headers)
|
||||
entry.Response.Code = int64(ev.HTTPStatusCode)
|
||||
entry.Response.Locations = ev.HTTPHeaders.Values("Location")
|
||||
entry.Response.Locations = ev.HTTPResponseHeaders.Values("Location")
|
||||
case *EventHTTPResponseBodySnapshot:
|
||||
entry.Response.Body.Value = string(ev.Data)
|
||||
entry.Response.BodyIsTruncated = ev.DataIsTruncated
|
||||
|
|
|
|||
Loading…
Reference in a new issue