| | 370 | |
|---|
| | 371 | general_header_fields = ["Cache-Control", "Connection", "Date", "Pragma", |
|---|
| | 372 | "Trailer", "Transfer-Encoding", "Upgrade", "Via", |
|---|
| | 373 | "Warning"] |
|---|
| | 374 | response_header_fields = ["Accept-Ranges", "Age", "ETag", "Location", |
|---|
| | 375 | "Proxy-Authenticate", "Retry-After", "Server", |
|---|
| | 376 | "Vary", "WWW-Authenticate"] |
|---|
| | 377 | entity_header_fields = ["Allow", "Content-Encoding", "Content-Language", |
|---|
| | 378 | "Content-Length", "Content-Location", "Content-MD5", |
|---|
| | 379 | "Content-Range", "Content-Type", "Expires", |
|---|
| | 380 | "Last-Modified"] |
|---|
| | 381 | |
|---|
| | 382 | _header_order_map = {} |
|---|
| | 383 | for _ in general_header_fields: |
|---|
| | 384 | _header_order_map[_] = 0 |
|---|
| | 385 | for _ in response_header_fields: |
|---|
| | 386 | _header_order_map[_] = 1 |
|---|
| | 387 | for _ in entity_header_fields: |
|---|
| | 388 | _header_order_map[_] = 2 |
|---|
| | 389 | |
|---|
| | 390 | |
|---|
| 387 | | cpg.response.headers.append((key, str(value))) |
|---|
| | 409 | headers.append((order, (key, str(value)))) |
|---|
| | 410 | # RFC 2616: '... it is "good practice" to send general-header fields |
|---|
| | 411 | # first, followed by request-header or response-header fields, and |
|---|
| | 412 | # ending with the entity-header fields.' |
|---|
| | 413 | headers.sort() |
|---|
| | 414 | cpg.response.headers = [item[1] for item in headers] |
|---|