title: How do I set a non-standard User-Agent using spray-client?
body: <p>I'm building an application for a Telco, using Scala and Akka, and need to communicate with Account Information and Refill servers using the <a href="http://www.mofokom.biz/site/doc/ra-air-ucip-1.pdf" rel="nofollow">UCIP protocol</a>. </p>
  
  <p>UCIP is a simple protocol, built on XMLRPC; the only issue I'm having is that it requires clients to set the <code>User-Agent</code> header in the specific format <code>User-Agent: &lt;client name&gt;/&lt;protocol version&gt;/&lt;client version&gt;</code>, which spray parses as invalid.</p>
  
  <p>I tried creating a custom <code>User-Agent</code> header, inheriting from <code>spray.http.HttpHeader</code> but it still doesn't work. Here's what I've got so far:</p>
  
  <pre><code>import akka.actor.ActorSystem
  import akka.event.{Logging, LoggingAdapter}
  import spray.client.pipelining._
  import spray.http._
  import spray.httpx._
  
  case class `User-Agent`(value: String) extends HttpHeader {
      def lowercaseName: String = "user-agent"
      def name: String = "User-Agent"
      def render[R &lt;: Rendering](r: R): r.type = r ~~ s"User-Agent: $value"
  }
  
  class UcipClient(val url: String, val protocol: String, username: String, password: String) (implicit system: ActorSystem) {
  
      val log = Logging.getLogger(system, this)
      val logRequest: HttpRequest =&gt; HttpRequest = { r =&gt; log.debug(r.toString); r }
      val logResponse: HttpResponse =&gt; HttpResponse = { r =&gt; log.debug(r.toString); r }
  
      val pipeline = (
          addHeader(`User-Agent`("USSD-UCIP/%s/1.0".format(protocol)))
          ~&gt; addCredentials(BasicHttpCredentials(username, password))
          ~&gt; logRequest
          ~&gt; sendReceive
          ~&gt; logResponse
      )
  
      def send(req: UcipRequest) = pipeline(Post(url, req.getRequest))
  }
  </code></pre>
  
  <p>My requests keep returning "Sorry, Error occured: 403, Invalid protocol version Not defined", however, they return the correct response when I send the same details using <code>curl</code>.</p>
  
  <p>What am I missing, and is this even possible with spray-client? I've spent a fair bit of time checking the internets (which led me towards the custom header route), but still haven't figured this out...would really appreciate any help :-)</p>