title: Android Espresso MockWebserver setting cookies
body: <p>I tried to set cookies in my Android Instrumentationtest like this:</p>
  
  <pre><code>  @Override
  protected MockResponse onDispatch(RecordedRequest request) {
      if (request.getPath().startsWith("/?loginkulcs=")) {
          MockResponse response = new MockResponse()
                  .setStatus(new BasicStatusLine(new ProtocolVersion("HTTP",1,1), 302, "Moved Temporarily").toString())
                  .setHeaders(new Headers.Builder()
                          .add("Date", LocalDateTime.now().toString("ddd, dd MMM yyyy HH:mm:ss Z"))
                          .add("Server", "GlassFish Server Open Source Edition 3.1.2.2")
                          .add("X-Powered-By", "Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)")
                          .add("Location","https://xxx.jsp")
                          .add("Content-Type","text/html;charset=ISO-8859-1")
                          .add("Content-Language","en-US")
                          .add("Content-Length","227")
                          .add("Keep-Alive","timeout=5, max=100")
                          .add("Connection", "Keep-Alive")
                          .add("Set-Cookie", String.format("session_id=%s; Path=/xxx_teszt/", SESSION_ID))
                          .add("Set-Cookie", "regisztralt=IGEN; Path=/xxx_teszt/")
                          .add("Set-Cookie", "session_id=2084e74283d5073c5f4d324f17e2; Path=/xxx_teszt; HttpOnly")
                          .build());
          return response;
      }
      return null;
  
  }
  </code></pre>
  
  <p>the android client is an org.apache.http.impl.client.DefaultHttpClient and it reads cookies like this:</p>
  
  <p>client.getCookieStore().getCookies();</p>
  
  <p>But the result is null. 
  How can I set the cookies for this client?</p>
  
  <p>thx</p>
  
  <p>Zamek</p>