for (final HttpCookie candidate : HttpCookie.parse(header)) { if (candidate.getName().equals(name)) { cookie = RestResponse.cookie(candidate); break;
@Override public void invite(final String friend) throws IOException { final RestResponse response = this.request .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel("/page/links/link[@rel='invite']/@href") .method(Request.POST) .body().formParam("name", friend).back() .fetch() .as(RestResponse.class); if (response.status() == HttpURLConnection.HTTP_MOVED_PERM && response.cookie(RtFriends.COOKIE_RS_FLASH).getValue() .startsWith("incorrect+alias") ) { throw new Friends.UnknownAliasException( response.cookie(RtFriends.COOKIE_RS_FLASH).getValue() ); } response.assertStatus(HttpURLConnection.HTTP_SEE_OTHER); Logger.info(this, "friend '%s' invited", friend); }