<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import requests
import time
from requests.packages import urllib3

#Disable https insecure warnings for verify=False
urllib3.disable_warnings()

with open('1.ts','rb') as fh:
    file_data = fh.read()

def chunk_trans():
    for i in range(0, 3):
        time.sleep(0.1)
        yield file_data

req = requests.Request('POST', 'http://192.168.123.151/1.ts', data=chunk_trans(), headers={'Host':'a.b.c.d'})
prep = req.prepare()
s = requests.Session()
s.send(prep, timeout=2, verify=False, allow_redirects=False)"><pre class="notranslate"><code class="notranslate">import requests
import time
from requests.packages import urllib3

#Disable https insecure warnings for verify=False
urllib3.disable_warnings()

with open('1.ts','rb') as fh:
    file_data = fh.read()

def chunk_trans():
    for i in range(0, 3):
        time.sleep(0.1)
        yield file_data

req = requests.Request('POST', 'http://192.168.123.151/1.ts', data=chunk_trans(), headers={'Host':'a.b.c.d'})
prep = req.prepare()
s = requests.Session()
s.send(prep, timeout=2, verify=False, allow_redirects=False)
</code></pre></div>
<p dir="auto">On Server, I am seeing two "Host" headers are being sent. is that expected or I am not doing it correctly?</p>
<h2 dir="auto">Two Host header are being sent when doing chunk transfer with Session</h2>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">import requests<br>
requests.<strong>version</strong><br>
'2.22.0'</p>
</blockquote>
</blockquote>
</blockquote>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import requests
import time
from requests.packages import urllib3

#Disable https insecure warnings for verify=False
urllib3.disable_warnings()

with open('1.ts','rb') as fh:
    file_data = fh.read()

def chunk_trans():
    for i in range(0, 3):
        time.sleep(0.1)
        yield file_data

req = requests.Request('POST', 'http://192.168.123.151/1.ts', data=chunk_trans(), headers={'Host':'a.b.c.d'})
prep = req.prepare()
s = requests.Session()
s.send(prep, timeout=2, verify=False, allow_redirects=False)
"><pre class="notranslate"><code class="notranslate">import requests
import time
from requests.packages import urllib3

#Disable https insecure warnings for verify=False
urllib3.disable_warnings()

with open('1.ts','rb') as fh:
    file_data = fh.read()

def chunk_trans():
    for i in range(0, 3):
        time.sleep(0.1)
        yield file_data

req = requests.Request('POST', 'http://192.168.123.151/1.ts', data=chunk_trans(), headers={'Host':'a.b.c.d'})
prep = req.prepare()
s = requests.Session()
s.send(prep, timeout=2, verify=False, allow_redirects=False)

</code></pre></div>
<p dir="auto">Actual Output: Two host headers are seen on server side.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Host: 192.168.123.151
Host: a.b.c.d
Transfer-Encoding: chunked"><pre class="notranslate"><code class="notranslate">Host: 192.168.123.151
Host: a.b.c.d
Transfer-Encoding: chunked
</code></pre></div>
<hr>
<p dir="auto">only "a.b.c.d" host header should come.</p>