@classmethod<EOL><INDENT>def get_canonical_headers(cls, req, include=None):<DEDENT>
if include is None:<EOL><INDENT>include = cls.default_include_headers<EOL><DEDENT>include = [x.lower() for x in include]<EOL>headers = req.headers.copy()<EOL>if '<STR_LIT:host>' not in headers:<EOL><INDENT>headers['<STR_LIT:host>'] = urlparse(req.url).netloc.split('<STR_LIT::>')[<NUM_LIT:0>]<EOL><DEDENT>cano_headers_dict = {}<EOL>for hdr, val in headers.items():<EOL><INDENT>hdr = hdr.strip().lower()<EOL>val = cls.amz_norm_whitespace(val).strip()<EOL>if (hdr in include or '<STR_LIT:*>' in include or<EOL>('<STR_LIT>' in include and hdr.startswith('<STR_LIT>') and not<EOL>hdr == '<STR_LIT>')):<EOL><INDENT>vals = cano_headers_dict.setdefault(hdr, [])<EOL>vals.append(val)<EOL><DEDENT><DEDENT>cano_headers = '<STR_LIT>'<EOL>signed_headers_list = []<EOL>for hdr in sorted(cano_headers_dict):<EOL><INDENT>vals = cano_headers_dict[hdr]<EOL>val = '<STR_LIT:U+002C>'.join(sorted(vals))<EOL>cano_headers += '<STR_LIT>'.format(hdr, val)<EOL>signed_headers_list.append(hdr)<EOL><DEDENT>signed_headers = '<STR_LIT:;>'.join(signed_headers_list)<EOL>return (cano_headers, signed_headers)<EOL>
Generate the Canonical Headers section of the Canonical Request.

Return the Canonical Headers and the Signed Headers strs as a tuple
(canonical_headers, signed_headers).

req     -- Requests PreparedRequest object
include -- List of headers to include in the canonical and signed
           headers. It's primarily included to allow testing against
           specific examples from Amazon. If omitted or None it
           includes host, content-type and any header starting 'x-amz-'
           except for x-amz-client context, which appears to break
           mobile analytics auth if included. Except for the
           x-amz-client-context exclusion these defaults are per the
           AWS documentation.