const PRUnichar *header = 0; (void)aHeader->GetUnicode(&header); (void)httpChannel->SetResponseHeader( NS_ConvertUCS2toUTF8(header), NS_ConvertUCS2toUTF8(aValue), PR_TRUE);
const char* header; (void)aHeader->GetUTF8String(&header); (void)httpChannel->SetResponseHeader(nsDependentCString(header), NS_ConvertUCS2toUTF8(aValue), PR_TRUE);
HTMLContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,                                   nsIHTMLContent* aContent){  nsresult rv = NS_OK;  // XXX necko isn't going to process headers coming in from the  // parser  mDocument->SetHeaderData(aHeader, aValue);  // see if we have a refresh "header".  if (aHeader == nsHTMLAtoms::refresh) {    // first get our baseURI    nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(mWebShell, &rv);    if (NS_FAILED(rv)) {      return rv;    }    nsCOMPtr<nsIURI> baseURI;    nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(docShell);    rv = webNav->GetCurrentURI(getter_AddRefs(baseURI));    if (NS_FAILED(rv)) {      return rv;    }    nsCOMPtr<nsIRefreshURI> reefer = do_QueryInterface(mWebShell);    if (reefer) {      rv = reefer->SetupRefreshURIFromHeader(baseURI,                                             NS_ConvertUCS2toUTF8(aValue));      if (NS_FAILED(rv)) {        return rv;      }    }  } else if (aHeader == nsHTMLAtoms::setcookie) {    nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(mWebShell, &rv);    if (NS_FAILED(rv)) {      return rv;    }    nsCOMPtr<nsICookieService> cookieServ =      do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);    if (NS_FAILED(rv)) {      return rv;    }    // Get a URI from the document principal    // We use the original codebase in case the codebase was changed    // by SetDomain    nsCOMPtr<nsIPrincipal> docPrincipal;    rv = mDocument->GetPrincipal(getter_AddRefs(docPrincipal));    if (NS_FAILED(rv) || !docPrincipal) {      return rv;    }    nsCOMPtr<nsIAggregatePrincipal> agg(do_QueryInterface(docPrincipal, &rv));    // Document principal should always be an aggregate    NS_ENSURE_SUCCESS(rv, rv);    nsCOMPtr<nsIPrincipal> originalPrincipal;    rv = agg->GetOriginalCodebase(getter_AddRefs(originalPrincipal));    nsCOMPtr<nsICodebasePrincipal> originalCodebase =      do_QueryInterface(originalPrincipal, &rv);    if (NS_FAILED(rv)) {      // Document's principal is not a codebase (may be system), so      // can't set cookies      return NS_OK;    }    nsCOMPtr<nsIURI> codebaseURI;    rv = originalCodebase->GetURI(getter_AddRefs(codebaseURI));    NS_ENSURE_SUCCESS(rv, rv);    char *cookie = ToNewUTF8String(aValue);    nsCOMPtr<nsIScriptGlobalObject> globalObj;    nsCOMPtr<nsIPrompt> prompt;    mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));    if (globalObj) {      nsCOMPtr<nsIDOMWindowInternal> window (do_QueryInterface(globalObj));      if (window) {        window->GetPrompter(getter_AddRefs(prompt));      }    }    nsCOMPtr<nsIHttpChannel> httpChannel;    if (mParser) {      nsCOMPtr<nsIChannel> channel;      if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {        httpChannel = do_QueryInterface(channel);      }    }    rv = cookieServ->SetCookieString(codebaseURI, prompt, cookie, httpChannel);    nsCRT::free(cookie);    if (NS_FAILED(rv)) {      return rv;    }  } else if (aHeader == nsHTMLAtoms::link) {    rv = ProcessLinkHeader(aContent, aValue);  }  else if (aHeader == nsHTMLAtoms::msthemecompatible) {    // Disable theming for the presshell if the value is no.    nsAutoString value(aValue);    if (value.EqualsIgnoreCase("no")) {      nsCOMPtr<nsIPresShell> shell;      mDocument->GetShellAt(0, getter_AddRefs(shell));      if (shell)        shell->DisableThemeSupport();    }  }  else if (mParser) {    // we also need to report back HTTP-EQUIV headers to the channel    // so that it can process things like pragma: no-cache or other    // cache-control headers. Ideally this should also be the way for    // cookies to be set! But we'll worry about that in the next    // iteration    nsCOMPtr<nsIChannel> channel;    if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {      nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));      if (httpChannel) {        const PRUnichar *header = 0;        (void)aHeader->GetUnicode(&header);        (void)httpChannel->SetResponseHeader(                       NS_ConvertUCS2toUTF8(header),                       NS_ConvertUCS2toUTF8(aValue),                       PR_TRUE);      }    }  }  return rv;}