title: Golang gRPC stream XML file (server-side)
body: <p><strong>The goal:</strong> When I open <code>localhost:9000/xml</code> page in the browser I would like to see xml content (which is large). I use gRPC server with <a href="https://github.com/grpc-ecosystem/grpc-gateway" rel="nofollow noreferrer">grpc-gateway</a> as a proxy.</p>
  <p>To send my xml file I use server-side stream and send <code>google.api.HttpBody</code> message with <code>text/xml</code> content-type. Below is a part of my server code for streaming xml:</p>
  <pre><code>reader := bytes.NewReader(data) // &quot;data&quot; is a large xml file
  buffer := make([]byte, 1024)
  
  for {
      n, err := reader.Read(buffer)
      if err == io.EOF {
          break
      }
      if err != nil {
          return status.Error(codes.Internal, &quot;&quot;)
      }
  
      if err := stream.Send(&amp;httpbody.HttpBody{
          ContentType: &quot;text/xml&quot;,
          Data:        buffer[:n],
      }); err != nil {
          return status.Error(codes.Internal, &quot;&quot;)
      }
  }
  </code></pre>
  <p>Unfortunately when I open <code>localhost:9000/xml</code> in the browser I see that my xml response is broken. Every 1025 byte starts on a new line, for example:</p>
  <pre><code>...
  ...
  &lt;loc&gt;https://example.com/books/1&lt;/l
          oc&gt;
  ...
  ...
  </code></pre>
  <p><strong>How can I stream a large xml content and not break it?</strong></p>