nsCOMPtr<nsIInputStream> dataStream; nsresult rv = NS_NewCharInputStream(getter_AddRefs(dataStream), aData); if (NS_FAILED(rv)) return rv;
nsresult rv;  nsCOMPtr<nsIStringInputStream> dataStream (do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv)); NS_ENSURE_SUCCESS(rv, rv);  rv = dataStream->SetData(aData, strlen(aData)); NS_ENSURE_SUCCESS(rv, rv);
nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) {    nsCOMPtr<nsIInputStream> dataStream;    nsresult rv = NS_NewCharInputStream(getter_AddRefs(dataStream), aData);    if (NS_FAILED(rv)) return rv;    PRUint32 avail;    dataStream->Available(&avail);    return aListener->OnDataAvailable(request, nsnull, dataStream, 0, avail);}