title: Angular 5 HttpClient post raw binary data
body: <p>My WebApp needs to communicate with my server via ProtBuf. For this to be possible, I need to be able to post the raw binary data.  </p>
  
  <p>This is the code I'm using right now. The problem with this is that <code>HttpClient</code> encodes the Uint8Array as a JSON array, so that the result is not a valid protobuffer anymore:</p>
  
  <pre><code>const message = LoginRequest.fromObject({
    code: code,
    username: username,
    password: password
  });
  
  const buffer: Uint8Array = LoginRequest.encode(message).finish();
  
  this.http.post('https://api.myserver.com', buffer)
    .subscribe(/*...*/);
  </code></pre>
  
  <p><code>HttpClient.post</code> accepts some options, where you can set <code>responseType</code> to <code>json</code>, <code>text</code>, <code>blob</code> or <code>arraybuffer</code>. But this just sets the expected type of the response, the body of the request still gets encoded as JSON.</p>
  
  <p>Does <code>HttpClient</code> have the possibility to send unencoded bodies?</p>
  
  <p>Edit: This is the body I receive at the server:</p>
  
  <p><code>{"0":10,"1":3,"2":97,"3":98,"4":99,"5":18,"6":5,"7":97,"8":100,"9":109,"10":105,"11":110,"12":26,"13":8,"14":112,"15":97,"16":115,"17":115,"18":119,"19":111,"20":114,"21":100}</code></p>