Search completed in 1.19 seconds.
6 results for "nsistringinputstream":
XPCOM Stream Guide
Mozilla › Tech › XPCOM › Guide › Streams
ta storage. Each of these implements nsIInputStream. Primitive Input Streams Type Native Class Contract ID Interface How to bind to a data source Generic nsStorageInputStream N/A nsIInputStream, nsISeekableStream storageStream.newInputStream(); String (8-bit characters) nsStringStream @mozilla.org/io/string-input-stream;1 nsIStringInputStream stream.setData(data, length); File nsFileInputStream @mozilla.org/network/file-input-stream;1 nsIFileInputStream stream.init(file, ioFlags, perm, behaviorFlags); ZIP nsJARInputStream N/A nsIInputStream zipReader.getInputStream(zipEntry); Similarly, each of these implements nsIOutputStream. Primitive Output Streams Type Nat...
... This is also a synchronous (blocking) operation, so if you're in JavaScript, consider using NetUtil.jsm as described below. A note about Unicode...
...addEntryStream("/path/to/zipped/file", modTime, compression, stream, queueForLater); // if queued for later operations, and all operations are queued zipWriter.processQueue(); // when we don't need the zipWriter anymore zipWriter.close(); Concatenating input streams var StringStream = Components.Constructor("@mozilla.org/io/string-input-stream;1", "nsIStringInputStream", "setData"); function buildStream(data) { return new StringStream(data, data.length); } function run_test() { var str1 = buildStream("We "); var str2 = buildStream("will "); var str3 = buildStream("rock "); var str4 = buildStream("you!"); var check = "We will rock you!"; var multi = Components.classes["@mozilla.org/io/multiplex-input-st...
...lasses["@mozilla.org/scriptableinputstream;1"] .createInstance(Components.interfaces.nsIScriptableInputStream); inStream.init(multi); var data = inStream.read(inStream.available()); // check == data; } Creating copies of an input stream var StringStream = Components.Constructor("@mozilla.org/io/string-input-stream;1", "nsIStringInputStream", "setData"); var InputStream = Components.Constructor("@mozilla.org/scriptableinputstream;1", "nsIScriptableInputStream", "init"); function buildStream(data) { return new StringStream(data, data.length); } Components.utils.import("resource://gre/modules/NetUtil.jsm"); ...
Post data to window - Archive of obsolete content
Archive › Add-ons › Code snippets › Post data to window
e1=data1&name2=data2&...", so you must convert it before passing the data to one of the methods. Here is an example: var dataString = "name1=data1&name2=data2"; // POST method requests must wrap the encoded text in a MIME // stream const Cc = Components.classes; const Ci = Components.interfaces; var stringStream = Cc["@mozilla.org/io/string-input-stream;1"]. createInstance(Ci.nsIStringInputStream); if ("data" in stringStream) // Gecko 1.9 or newer stringStream.data = dataString; else // 1.8 or older stringStream.setData(dataString, dataString.length); var postData = Cc["@mozilla.org/network/mime-input-stream;1"]. createInstance(Ci.nsIMIMEInputStream); postData.addHeader("Content-Type", "application/x-www-form-urlencoded"); postData.addContentLength = true; postData.set...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
Archive › Add-ons › Migrating from Internal Linkage to Frozen Linkage
nsISupportsArray is bad! Don't use it in new code. Use nsIArray instead. (See XPCOM:Arrays.) nsCOMPtr<nsISupportsArray> array; - rv = NS_NewISupportsArray(getter_AddRefs(array)); + array = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); - nsCOMPtr<nsIInputStream> rawStream;- rv = NS_NewByteInputStream(getter_AddRefs(rawStream),- (const char*)data, length); + nsCOMPtr<nsIStringInputStream> rawStream =+ do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);+ NS_ENSURE_SUCCESS(rv, rv);++ rv = rawStream->SetData((const char*)data, length); NS_ENSURE_SUCCESS(rv, rv); nsIStringInputStream is not frozen (and thus, not available in the Gecko SDK as currently published). In order to use this interface in your code, you will need to get the IDL files from the source (via CVS, from ...
Chapter 4: Using XPCOM—Implementing advanced processes - Archive of obsolete content
Archive › Add-ons › Overlay Extensions › Firefox addons developer guide › Using XPCOM—Implementing advanced processes
= ioService.newURI('http://www.gihyo.co.jp/', null, null); browser.loadURI('http://www.gihyo.co.jp/magazines/SD', referrer); Listing 22: Loading a page with data transmitted via the POST method var content = encodeURIComponent('password=foobar'); var referrer = null; var postData = Components.classes['@mozilla.org/io/string-input-stream;1'] .createInstance(Components.interfaces.nsIStringInputStream); content = 'Content-Type: application/x-www-form-urlencoded\n'+ 'Content-Length: '+content.length+'\n\n'+ content; postData.setData(content, content.length); var flags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE; browser.loadURIWithFlags('http://piro.sakura.ne.jp/', flags, referrer, null, postData); << PreviousNext >> ...
Creating Sandboxed HTTP Connections
Mozilla › Creating sandboxed HTTP connections
ance is created, after which the setData method is called. The first argument is the POST data as a string, while the second argument is the length of that data. In this case, the data is URL encoded, meaning that the string should look like this: foo=bar&baz=eek. var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"] .createInstance(Components.interfaces.nsIStringInputStream); inputStream.setData(postData, postData.length); Next, the nsIChannel is QIed to an nsIUploadChannel. Its setUploadStream method is called, passing in the nsIInputStream and the type (in this case, "application/x-www-form-urlencoded"): var uploadChannel = gChannel.QueryInterface(Components.interfaces.nsIUploadChannel); uploadChannel.setUploadStream(inputStream, "application/x-www-form-urlenco...
NetUtil.jsm
Mozilla › JavaScript code modules › NetUtil.jsm
0666); // Then, we need an output stream to our output file. var ostream = Cc["@mozilla.org/network/file-output-stream;1"]. createInstance(Ci.nsIFileOutputStream); ostream.init(file, -1, -1, 0); // Finally, we need an input stream to take data from. const TEST_DATA = "this is a test string"; let istream = Cc["@mozilla.org/io/string-input-stream;1"]. createInstance(Ci.nsIStringInputStream); istream.setData(TEST_DATA, TEST_DATA.length); NetUtil.asyncCopy(istream, ostream, function(aResult) { if (!Components.isSuccessCode(aResult)) { // an error occurred! } }) asyncFetch() The asyncFetch() method opens an input source, asynchronously, and gives an nsIInputStream containing the data obtained to the callback provided. The callback may then consume data from the input strea...