void TCookieJar::addCookie(const TCookie &cookie) { for (QMutableListIterator<TCookie> it(*this); it.hasNext(); ) { if (it.next().name() == cookie.name()) { it.remove(); break; } } append(cookie); }
/*! \~english Adds the cookie to the internal list of cookies. \~japanese クッキーをHTTPレスポンスに追加する */ bool TActionController::addCookie(const TCookie &cookie) { QByteArray name = cookie.name(); if (name.isEmpty() || name.contains(';') || name.contains(',') || name.contains(' ') || name.contains('\"')) { tError("Invalid cookie name: %s", name.data()); return false; } cookieJar.addCookie(cookie); response.header().removeAllRawHeaders("Set-Cookie"); for (QListIterator<TCookie> i(cookieJar.allCookies()); i.hasNext(); ) { response.header().addRawHeader("Set-Cookie", i.next().toRawForm()); } return true; }