title: Sending text via an HTTP POST request
body: <p>There is an app endpoint on a remote expecting text via HTTP POST. </p>
  
  <p>Can this be done by simply sending a text file?
  specifically, I am using curl:</p>
  
  <pre><code>curl -X POST -d lines.txt http://theserver.com/theendpoint
  </code></pre>
  
  <p>Or must I send the text as a stream, using, let's say, a Python script? I tried this:</p>
  
  <pre><code>def send_to_server(text):
      url = 'http://theserver.com/theendpoint'
      headers = {'content-type': 'text/plain'}
      r = requests.post(url=url, data=text, headers=headers)
      return r
  </code></pre>
  
  <p>where <code>text</code> is created by:</p>
  
  <pre><code>output = io.StringIO()
  output.write( some_function() ) # getting some text from a different function 
  text = output.getvalue()
  </code></pre>
  
  <p>In other words - is the app on the server getting what it expects in both ways?</p>