<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://sessrumnir.net/fernseher/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=96.42.70.86</id>
	<title>Fernseher - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://sessrumnir.net/fernseher/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=96.42.70.86"/>
	<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=Special:Contributions/96.42.70.86"/>
	<updated>2026-08-19T06:05:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=MIDI_and_the_organ_project&amp;diff=2125</id>
		<title>MIDI and the organ project</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=MIDI_and_the_organ_project&amp;diff=2125"/>
		<updated>2009-02-24T02:53:42Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: /* Chips to use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;MIDI standard is out there. Also good is the RTP-MIDI RFC, for putting MIDI data into a stream and whatnot.&lt;br /&gt;
&lt;br /&gt;
The basics, as I think we will be using them:&lt;br /&gt;
&lt;br /&gt;
Packet basics (we&amp;#039;ll only be using 3 byte packet forms):&lt;br /&gt;
&lt;br /&gt;
 1 &amp;lt;3: opcode&amp;gt; &amp;lt;4: channel&amp;gt; 0 &amp;lt;7: arg1&amp;gt; 0 &amp;lt;7: arg2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, a status byte, with the high bit on (0x80-0xFF), and two argument bytes, with the high bit off (0x00-0x7F).&lt;br /&gt;
&lt;br /&gt;
opcodes of relevance:&lt;br /&gt;
*0x0: key off.  arg1 is the key number, arg2 is the velocity.  We will always use velocity of 0x40.&lt;br /&gt;
*0x1: key on. arg1 is the key number, arg2 is the velocity.  We will always use the velocity of 0x40.&lt;br /&gt;
*0x3: control change.  arg1 is the control number (0x01 is modulation wheel, 0x0B is the expression pedal), arg2 is the new control value, from 0x00 - 0x7F (Note:  If we need more than 127 steps, add 0x20 to the control number, and thats the control number to use to send the least significant 7-bits of the value.  The value sent with the base control number is considered to be the most significant 7-bits of the value.  This ensures that if just read the base control number, you set the control to approximately the correct percentage of fully off/fully on.)&lt;br /&gt;
&lt;br /&gt;
For channels, we will use:&lt;br /&gt;
*0x0: Great (Solo) Manual&lt;br /&gt;
*0x1: Swell (Accompaniment) Manual&lt;br /&gt;
*0x2: Choir (below Great) Manual, if present&lt;br /&gt;
*0x3: Solo (above Swell) Manual, if present&lt;br /&gt;
*0x4: Echo (above Solo) Manual, if present&lt;br /&gt;
*0x5: Third Pedalboard, if present, or the auxilary stop channel, covering additional stops for all manuals and pedals.&lt;br /&gt;
*0x6: Second Pedalboard, if present, or the main stop channel, covering all stops for all manuals and pedals.&lt;br /&gt;
*0x7: Main Pedalboard&lt;br /&gt;
*0x8: Great stops only&lt;br /&gt;
*0x9: Swell stops only&lt;br /&gt;
*0xA: Choir stops only&lt;br /&gt;
*0xB: Solo stops only&lt;br /&gt;
*0xC: Echo stops only&lt;br /&gt;
*0xD: Third Pedalboard stops only&lt;br /&gt;
*0xE: Second Pedalboard stops only&lt;br /&gt;
*0xF: Main Pedalboard stops only&lt;br /&gt;
&lt;br /&gt;
Our initial organ will only use channels 0x0-0x1, 0x6-0x7.&lt;br /&gt;
&lt;br /&gt;
Each keyboard channel (0x0-0x7) gets its own control set.  For our organ, where the modulation wheel and expression pedal control all divisions equally, each control change gets sent for each active channel... or maybe just for great, and the software will figure out that they control all the stuff.  Note, we may not hook up the modulation wheel when we begin.  It&amp;#039;d be kinda a lot harder to make work right, I think.&lt;br /&gt;
&lt;br /&gt;
We will be building channel combination boards, that take an enable and a sub-channel address, and read back the contents of the addressed buffer.  4 bits of address gets 16 buffers.  At 8 bits per buffer, thats 128 inputs for each channel.  That matches with midi&amp;#039;s numbering scheme.  Alternatively, if you take the LSB of the true channel, and feed it to the 4th address bit of the channel board, and only decode the top 3 bits of the channel to determine channel board enable, you can duplex your channel boards, since we will only be using under 64 inputs per channel.  The AVR firmware will have an MIDI offset value for each channel to add to the number received from the board before sending as part of a MIDI command. For most subchannels, this will be 36.  Will probably just use an offset of 0 for the stop channels.&lt;br /&gt;
&lt;br /&gt;
Using the split channel board design, we only need two channel boards for our organ.  The main board will be designed to use the channel boards in split mode, and will never probably use the split-mode stop channels (0x8-0xF), so it will only have 4 plugs for channel boards, 0x0-0x1, 0x2-0x3, 0x4-0x5, and 0x6-0x7.  The initial organ will only use the first and last of these plugs, so we don&amp;#039;t even need to populate the board positions for the other channel boards.&lt;br /&gt;
&lt;br /&gt;
Also, I think we might want to put all the switch pull-up resistors on the manuals themselves, soldered to the key tabs.  This will eliminate a lot of crap on the boards, and keep the board design uniform, since the different keys will need different pull-ups.  The manuals, with their 5k internal resistance, will need 50k (or so) pull-ups to 5V, and the pedals and stops, with no internal resistance, will need just 10k (or so) pull-ups to 5V.  Each manual will get a separate power and ground plug for the pull-ups and grounds, so the connectors for the keys don&amp;#039;t need a pin for ground or power, I don&amp;#039;t think... Though if there is room, I guess we could send it along there, too.  Can&amp;#039;t hurt anything, provided the wires support enough current for the crazy case of all the stop pulled or keys pressed or something.  Given a max of 64 inputs to a half-channel, and only 61 keys on a full manual, we can use 2x36 pin connectors for the manuals, and 1x36 pin connector for the pedalboards, and 1x36 pin connector for the stop boards.  Thats 6 total 36 pin connectors, male and female, solder cup and through-hole.&lt;br /&gt;
&lt;br /&gt;
Channel board to main board connectors will have an 8-bit data bus, 4-bit address bus, a power, ground, enable, and identify(?) pins (16 total).  Should be able to use IDC connectors and ribbon cable here.&lt;br /&gt;
&lt;br /&gt;
===Simple algorithm for key change detection===&lt;br /&gt;
After reading a byte from the buffers, we xor it with the copy of the byte from last time, then store the new version in the copy location.  We then start looking at the lsb of the xor&amp;#039;ed byte.  If its a 1, we send a key on if the lsb of the read byte is a 1, and a key off if the lsb of the read byte is a 0.  We then shift right and do that again.  We do that 8 times, once for each bit in that byte.  Then we can move on to the next valid address for that channel, write out the address, read back the buffer value, xor, store, analyze, etc.  Note, we can speed this up by checking if the xor byte is identically 0x00, in which case we don&amp;#039;t have to analyze it, it hasn&amp;#039;t changed.  This will be the usual case!  Only occasionally (in sample time), will things change, and usually only on one bit, and thus one buffer, amongst all the channels and buffers.  This should help us keep up to speed.&lt;br /&gt;
&lt;br /&gt;
Once we are done reading all the channel board buffers, we can check the expression pedals and other variable controls for new values, and possibly send control change events.  After all this, we actually send the MIDI bytes as we have determined them to need to be for this time around, and go to sleep until our next sample time.&lt;br /&gt;
&lt;br /&gt;
Not sure what the latency of the serial to USB conversion is in FTDI, but it could be as bad as a single byte in a single USB message....  Anyway, we want to build a buffer of bytes that need to get send over each sample time, with the RTP-MIDI spec used to make it a stream type thing.  This means: packet length, &amp;quot;timestamp&amp;quot;, first MIDI event, relative timestamps (should all be zero), subsequent MIDI events.&lt;br /&gt;
&lt;br /&gt;
===Chips to use===&lt;br /&gt;
*16x? 74HCT540  for the octal tri-state buffers, inverting (0.54, 20 pin dip)&lt;br /&gt;
*1x? 74HCT138  for 1 to 8 decoder (0.40, 16 pin dip)&lt;br /&gt;
*1x? 74HCT154  for 1 to 16 decoder (0.80, 24 pin dip)&lt;br /&gt;
*1x ATMega164P-20P for AVR controller, 20MHz, (4.82, 40 pin dip)&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=MailMessage&amp;diff=2110</id>
		<title>MailMessage</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=MailMessage&amp;diff=2110"/>
		<updated>2009-01-23T06:37:04Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: New page: This class represents a Mail Message for the Modjs environment, a straight up MIME message that, when receive processing is performed on it, gets converted from strict MIME RFC-204...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This class represents a Mail Message for the [[Modjs]] environment, a straight up [[MIME]] message that, when receive processing is performed on it, gets converted from strict MIME RFC-2045 compliant encodings and line foldings and whatnot, and when send processing is performed, gets converted to strict MIME RFC-2045 compliant encodings, line foldings, etc.  It is mostly a wrapper around [[MimeEntity]], with an additional property to help determine current encoding state, and several methods for encoding/decoding purposes.&lt;br /&gt;
&lt;br /&gt;
To create a new MailMessage:&lt;br /&gt;
 msg = new MailMessage([[MimeEntity]])&lt;br /&gt;
*Creates a mail message with the specified entity in it and converts to RFC-2045 compliant message string.&lt;br /&gt;
 msg = new MailMessage(textblob)&lt;br /&gt;
*Creates a mail message with the specified textblob in it.  This gets decoded and parsed into a [[MimeEntity]].&lt;br /&gt;
&lt;br /&gt;
Properties in MailMessages:&lt;br /&gt;
*entity: The [[MimeEntity]], decoded and everything, ready to be looked at and analyzed.&lt;br /&gt;
*mailable: The textblob, encoded and ready to be mailed out.&lt;br /&gt;
&lt;br /&gt;
Extra methods:&lt;br /&gt;
*msg.encode(): Encodes the entity to the mailable property.&lt;br /&gt;
*msg.decode(): Decodes the mailable text blob back into the entity&lt;br /&gt;
*status = msg.send([path and args string]): Calls msg.encode() and executes &amp;#039;/usr/bin/mail -t&amp;#039; (or the path argument and args) in a ProcessConnection() object, and then sends along the mailable textblob to it, followed by an EOF and then close() and returns the exit status.&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=HTTPResponse&amp;diff=2109</id>
		<title>HTTPResponse</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=HTTPResponse&amp;diff=2109"/>
		<updated>2009-01-23T06:16:40Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This class represents HTTP Response messages for the [[Modjs]] environment.  It contains information on the status line to be sent back in the response (or that was sent back in the response), as well as the [[MIME]] entity that is the resultant response data and response headers, as a [[MimeEntity]] object.  Primarily, this class represents a way for the [[Modjs]] script to return data to the requestor.  To this end, there are many obStack related methods.  These are only of use if this is _the_ response of the script. Otherwise, they don&amp;#039;t really do much.  They could, but they don&amp;#039;t :)  It can also be used to represent that data that is returned when manually requesting information from another HTTP server using a [[TCPConnection]].  In that case, the [[TCPConnection]] needs to be slurped up and passed to the HTTPResponse constructor.  For the prime response, the default Content-type: is set to text/html.  It can be changed easily though, of course.&lt;br /&gt;
&lt;br /&gt;
To create an HTTPResponse object, the entire response text should be passed to the constructor, like so:&lt;br /&gt;
 response = new HTTPResponse(response text blob)&lt;br /&gt;
&lt;br /&gt;
Response objects will contain the following properties.  They can be queried but usually should not be set directly, instead the obStack, print, setHeader, etc, methods should be used to ensure data consistency.&lt;br /&gt;
*statusCode: the status code of the response (such as 401, etc).  For prime, this is initially set to 200 (OK) and the contents of this, when the script ends, will get sent back to the client as the status code.&lt;br /&gt;
*statusMsg: a brief message used to more easily describe the statusCode.  In prime, this is initialized to OK, to go with the 200, but changing this has no real affect.&lt;br /&gt;
*prime: an indicator that this is the &amp;quot;prime&amp;quot; response, that is, the one used to respond back to the initial modjs apache request.  If this is on, things like sendHeaders(), print() and obstacks are actually important.&lt;br /&gt;
*headersSent: an indicator that headers have been sent back for this prime request already.  Therefore, new headers that are added, or old ones that get changed, will have no affect.&lt;br /&gt;
*obStack[]: stack of text blobs that can be written to, flushed, cleared, aborted, etc., to make handling responses that much easier.  Use them! They are great! Also, refer to PHP&amp;#039;s obstacks.&lt;br /&gt;
*entity: the actual [[MimeEntity]].  Don&amp;#039;t manual write to this, please.  Reading only!&lt;br /&gt;
&lt;br /&gt;
The methods on the object are:&lt;br /&gt;
 response.print(string|array of strings)&lt;br /&gt;
* prints the string or array of strings to the current obstack blob if there is one.  Otherwise, appends it to the entity body and sends it straight out!  If headers haven&amp;#039;t been sent yet, they would be at that point! beware!  Also the status line I guess?  Not certain how that works...&lt;br /&gt;
 response.addMimeData([[MimeEntity]]|array of [[MimeEntity]]s)&lt;br /&gt;
* adds the given mime entities to the entity tree, as though printed (meaning, through obstacks).  Content-type is not automatically changed, you have to do that beforehand! Including boundary generation (though that can be automatic, when setting to multipart content-type).&lt;br /&gt;
 response.sendFile([[File API|File]]|array of [[File API|File]]s)&lt;br /&gt;
* adds the contents of the given files to the body, as though printed (through obstacks, etc).  Note adding a File as an attachment would need to be done through a [[MimeEntity]] containing the file, etc.&lt;br /&gt;
 response.setHeader(name, value)&lt;br /&gt;
 response.setHeader([[MimeHeader]])&lt;br /&gt;
 response.setHeader(name, [[MimeHeader|MimeValue]])&lt;br /&gt;
* sets the given header in the top level mime entity to the given value.  This is as smart as it can be.  Hopefully you haven&amp;#039;t sent headers yet!  This will change the first header of the given name to the new value, or add a new header by that name.  If one already exists and you don&amp;#039;t want to overwrite it, you will need to set it in the entity itself.  This is quasi-safe... but don&amp;#039;t do anything else in there!&lt;br /&gt;
 response.setCookie(name, value[, expiration [,domain, etc.]])&lt;br /&gt;
* sets the given cookie to the new value.  If its a new cookie, you will need to specify the expiration and whatnot.  This will generate a Set-Cookie: header in the response.  Hopefully you haven&amp;#039;t sent headers yet.  If this is the prime response, this will also add the cookie/change the cookie of this name in the prime request. (maybe?)&lt;br /&gt;
 response.sendHeaders()&lt;br /&gt;
* sends the current set of headers (and the status line, maybe?) out over the wire, if this is the prime response.  Sets headersSent.  This will mean that subsequent changes to the prime response top level entity will not ever be sent out.&lt;br /&gt;
 response.obBegin()&lt;br /&gt;
* adds a new text blob to the obstack&lt;br /&gt;
 response.obClear()&lt;br /&gt;
* clears the top text blob on the obstack, but leaves it there&lt;br /&gt;
 response.obFlush()&lt;br /&gt;
* takes all the text of the top blob on the obstack and prints it to the lower one, or straight out.  Leaves the top blob (now empty) on the stack.&lt;br /&gt;
 response.obFinish()&lt;br /&gt;
* performs an obFlush() but also removes the top blob on the obstack&lt;br /&gt;
 response.obAbort()&lt;br /&gt;
* performs an obClear() but also removes the top blob on the obstack&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=Server_API&amp;diff=2108</id>
		<title>Server API</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=Server_API&amp;diff=2108"/>
		<updated>2009-01-23T06:14:50Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The server object is a global object representing the server interfaces for logging and environment and such in my [[Modjs]] implementation.&lt;br /&gt;
&lt;br /&gt;
Data members on the global server object:&lt;br /&gt;
*env: array of environment variables, including standard request headers and server information&lt;br /&gt;
&lt;br /&gt;
Functions on the global server object. Low-level Apache/spidermonkey interface methods. Please use appropriate File and HTTPResponse methods wherever possible.&lt;br /&gt;
*logNotice(string|array of strings): function to log a notice (or a list of notices) to the server error log&lt;br /&gt;
*logError(string|array of strings): function to log an error (or a list of errors) to the server error log&lt;br /&gt;
*status = runCmd(path, array of args): executes the given command on the server (with the httpd daemon&amp;#039;s permissions!).  Script execution will block until finished, and will return the exit status. arguments will be escaped or quoted as necessary&lt;br /&gt;
*sendHeaders(): Push the headers to the client&lt;br /&gt;
*sendString(string|array of strings): Print the strings specified to the client.&lt;br /&gt;
*sendFile(path): Print the strings specified to the client.&lt;br /&gt;
*setOutgoingHeader(key, value): sets the first outgoing header of the given keyname to value, and removes any extra headers of that name.  If key is content-type, content-encoding, or content-language, also sets the appropriate entry in the request_rec.&lt;br /&gt;
*addOutgoingHeader(key, value): adds the outgoing header of the given keyname to value.  If key is content-type, content-encoding, or content-language, also sets the appropriate entry in the request_rec.&lt;br /&gt;
*string = base64encode(string): encodes the string in base64&lt;br /&gt;
*string = base64decode(string): decodes the string from base64&lt;br /&gt;
*include(path): Runs the script specified by path in the current context&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=HTTPRequest&amp;diff=2107</id>
		<title>HTTPRequest</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=HTTPRequest&amp;diff=2107"/>
		<updated>2009-01-23T05:35:49Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTTPRequest class represents an HTTP Request message for my [[Modjs]] environment.  It contains a request line and other information about the requestor, and a [[MIME]] entity ([[MimeEntity]]) for the request headers and data.  Its primary use will be for the script writer to see the request from the browser to the server, and what data they are sending over.  It will do a little bit to parse out cookie variables, query variables, and post data variables to make the script writer&amp;#039;s life easier.  It can also be tied back to a [[HTTPResponse]] object to make inclusion of cookie headers mostly seemless when new cookies are defined and the response is sent back with them.&lt;br /&gt;
&lt;br /&gt;
When a [[Modjs]] script builds a completely new HTTPRequest object in order to send it over a [[TCPConnection]] or the like to a different, remote, server, it will behave a little bit differently, in that, rather than parsing the headers and request data in order to get cookies/queries/posts, it will have the ability to unparse those variables sets back into headers and request data, as needed (and only if requested).  And not cookies.  Just too much work for too little benefit.&lt;br /&gt;
&lt;br /&gt;
To create a new HTTPRequest object, the constructor is called:&lt;br /&gt;
 request = new HTTPRequest(host [,method [,path [,query [,version]]]])&lt;br /&gt;
&lt;br /&gt;
Note that except for host, the rest of the arguments could be passed as one string. They are essentially joined and reparsed to verify that the correct syntax is used for the request line.  host sets the required Host: header in the mimeentity on creation.  If the method is POST, the Content-type: header also gets set to the default value of application/form-data.&lt;br /&gt;
&lt;br /&gt;
This could throw an exception if method or query string are malformed:&lt;br /&gt;
 HTTPRequestException&lt;br /&gt;
&lt;br /&gt;
The object will have these properties:&lt;br /&gt;
*method: the request method&lt;br /&gt;
*path: the request path&lt;br /&gt;
*query: the request query&lt;br /&gt;
*host: the request host&lt;br /&gt;
*protocol: the request protocol version&lt;br /&gt;
*client: the requesting client ip&lt;br /&gt;
*prime: indicates whether this is the &amp;quot;prime&amp;quot; request, that is, the one that started the script up and needs to be quasi-special.&lt;br /&gt;
*entity: the [[MimeEntity]] for the data in this request, including headers.&lt;br /&gt;
*queryVars: the query is parsed and proper variables are put in here as name/value pairs.  Last one sticks. If you reuse a name, you&amp;#039;ll have to go to the real query to get both values.  On outgoing requests, this will get slurped up and urlencoded and _added_ to the query property as part of the query string in the request line.  Be aware!&lt;br /&gt;
*cookieVars: the Cookie and Cookie2 headers are parsed and proper variables are put in here as name/value pairs.  If there are duplicate names, the last one sticks. Go to the actual headers if you need more, or property values.  Note that this is not a magic cookie jar.  For the outgoing response, if you need to add new cookies, you must add the cookie using the [[HTTPResponse]] addCookie() method.  For outgoing requests, the cookie variables placed in here do not get magically merged into the appropriate Cookie: header, since it doesn&amp;#039;t have enough information.&lt;br /&gt;
*postVars: If the method is POST and the [[MIME]] entity is correct, posted variables get parsed and put in here as name/value pairs.  If there are dups, again, the last one sticks.  You may have to actually decode the entity if you need more details.  On outgoing requests, this will get slurped up and put as variables in the POST data, in the appropriate section, depending on current content-type and method, etc.&lt;br /&gt;
&lt;br /&gt;
The object has a couple methods, toString() which essentially converts to a single string, appropriate for sending over a TCPConnection.  This will do queryVars and postVars recombination, if there are any variables there.  Be aware!  It will also use proper CRLF EOLs for headers (I think?).  Also, getRequestString() which combines the request information and returns the request line in the current state based on properties and query variables.&lt;br /&gt;
 string = request.toString()&lt;br /&gt;
 string = request.getRequestString()&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=HTTPRequest&amp;diff=2106</id>
		<title>HTTPRequest</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=HTTPRequest&amp;diff=2106"/>
		<updated>2009-01-23T05:29:28Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTTPRequest class represents an HTTP Request message for my [[Modjs]] environment.  It contains a request line and other information about the requestor, and a [[MIME]] entity ([[MimeEntity]]) for the request headers and data.  Its primary use will be for the script writer to see the request from the browser to the server, and what data they are sending over.  It will do a little bit to parse out cookie variables, query variables, and post data variables to make the script writer&amp;#039;s life easier.  It can also be tied back to a [[HTTPResponse]] object to make inclusion of cookie headers mostly seemless when new cookies are defined and the response is sent back with them.&lt;br /&gt;
&lt;br /&gt;
When a [[Modjs]] script builds a completely new HTTPRequest object in order to send it over a [[TCPConnection]] or the like to a different, remote, server, it will behave a little bit differently, in that, rather than parsing the headers and request data in order to get cookies/queries/posts, it will have the ability to unparse those variables sets back into headers and request data, as needed (and only if requested).  And not cookies.  Just too much work for too little benefit.&lt;br /&gt;
&lt;br /&gt;
To create a new HTTPRequest object, the constructor is called:&lt;br /&gt;
 request = new HTTPRequest(host [,method [,path [,query [,version]]]])&lt;br /&gt;
&lt;br /&gt;
Note that except for host, the rest of the arguments could be passed as one string. They are essentially joined and reparsed to verify that the correct syntax is used for the request line.  host sets the required Host: header in the mimeentity on creation.  If the method is POST, the Content-type: header also gets set to the default value of application/form-data.&lt;br /&gt;
&lt;br /&gt;
This could throw an exception if method or query string are malformed:&lt;br /&gt;
 HTTPRequestException&lt;br /&gt;
&lt;br /&gt;
The object will have these properties:&lt;br /&gt;
*method: the request method&lt;br /&gt;
*path: the request path&lt;br /&gt;
*query: the request query&lt;br /&gt;
*host: the request host&lt;br /&gt;
*version: the request version&lt;br /&gt;
*client: the requesting client ip&lt;br /&gt;
*prime: indicates whether this is the &amp;quot;prime&amp;quot; request, that is, the one that started the script up and needs to be quasi-special.&lt;br /&gt;
*entity: the [[MimeEntity]] for the data in this request, including headers.&lt;br /&gt;
*queryVars: the query is parsed and proper variables are put in here as name/value pairs.  Last one sticks. If you reuse a name, you&amp;#039;ll have to go to the real query to get both values.  On outgoing requests, this will get slurped up and urlencoded and _added_ to the query property as part of the query string in the request line.  Be aware!&lt;br /&gt;
*cookieVars: the Cookie and Cookie2 headers are parsed and proper variables are put in here as name/value pairs.  If there are duplicate names, the last one sticks. Go to the actual headers if you need more, or property values.  Note that this is not a magic cookie jar.  For the outgoing response, if you need to add new cookies, you must add the cookie using the [[HTTPResponse]] addCookie() method.  For outgoing requests, the cookie variables placed in here do not get magically merged into the appropriate Cookie: header, since it doesn&amp;#039;t have enough information.&lt;br /&gt;
*postVars: If the method is POST and the [[MIME]] entity is correct, posted variables get parsed and put in here as name/value pairs.  If there are dups, again, the last one sticks.  You may have to actually decode the entity if you need more details.  On outgoing requests, this will get slurped up and put as variables in the POST data, in the appropriate section, depending on current content-type and method, etc.&lt;br /&gt;
&lt;br /&gt;
The object has a couple methods, toString() which essentially converts to a single string, appropriate for sending over a TCPConnection.  This will do queryVars and postVars recombination, if there are any variables there.  Be aware!  It will also use proper CRLF EOLs for headers (I think?).  Also, getRequestString() which combines the request information and returns the request line in the current state based on properties and query variables.&lt;br /&gt;
 string = request.toString()&lt;br /&gt;
 string = request.getRequestString()&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=Global_object_extensions&amp;diff=2105</id>
		<title>Global object extensions</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=Global_object_extensions&amp;diff=2105"/>
		<updated>2009-01-23T05:27:33Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A couple functions, I didn&amp;#039;t know where to put, but definitely wanted for my [[Modjs]] implementation, so they went onto the global object.  If I can think of a better place for them, they may move.  This page can also list all the classes I&amp;#039;ve added and that are available and whatnot.&lt;br /&gt;
&lt;br /&gt;
Used to convert an object to a JSON compliant string and back again:&lt;br /&gt;
 string = jsonEncode(object)&lt;br /&gt;
 object = jsonDecode(string)&lt;br /&gt;
&lt;br /&gt;
These could throw exceptions if the object or string cannot be converted or is otherwise malformed:&lt;br /&gt;
 JsonCodingException&lt;br /&gt;
&lt;br /&gt;
The global objects I&amp;#039;ve added are these:&lt;br /&gt;
*[[server API|server]]: Controls the environment, logging, and general low-level write back to the server, etc.&lt;br /&gt;
*[[HTTPRequest|request]]: The incoming HTTP Request from apache through [[Modjs]].  This is the prime [[HTTPRequest]].&lt;br /&gt;
*[[HTTPResponse|response]]: The outgoing HTTP Response from this script back to the client through apache and [[Modjs]].  This is the prime [[HTTPResponse]].&lt;br /&gt;
&lt;br /&gt;
Constructors on the global object now:&lt;br /&gt;
*[[File API|File]]&lt;br /&gt;
*[[HTTPRequest]]&lt;br /&gt;
*[[HTTPResponse]]&lt;br /&gt;
*[[MailMesage]]&lt;br /&gt;
*[[MimeEntity]]&lt;br /&gt;
*[[MimeHeader]]&lt;br /&gt;
*[[MimeHeader|MimeValue]]&lt;br /&gt;
*[[MimeHeader|MimeProperty]]&lt;br /&gt;
*[[ProcessConnection]]&lt;br /&gt;
*[[TCPConnection]]&lt;br /&gt;
*[[DbConnection]]&lt;br /&gt;
*[[DbConnection|DbStatement]]&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=Global_object_extensions&amp;diff=2104</id>
		<title>Global object extensions</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=Global_object_extensions&amp;diff=2104"/>
		<updated>2009-01-23T05:26:40Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A couple functions, I didn&amp;#039;t know where to put, but definitely wanted for my [[Modjs]] implementation, so they went onto the global object.  If I can think of a better place for them, they may move.  This page can also list all the classes I&amp;#039;ve added and that are available and whatnot.&lt;br /&gt;
&lt;br /&gt;
Used to convert an object to a JSON compliant string and back again:&lt;br /&gt;
 string = jsonEncode(object)&lt;br /&gt;
 object = jsonDecode(string)&lt;br /&gt;
&lt;br /&gt;
These could throw exceptions if the object or string cannot be converted or is otherwise malformed:&lt;br /&gt;
 JsonCodingException&lt;br /&gt;
&lt;br /&gt;
The global objects I&amp;#039;ve added are these:&lt;br /&gt;
*[[server API|server]]: Controls the environment, logging, and general low-level write back to the server, etc.&lt;br /&gt;
*[[HTTPRequest|request]]: The incoming HTTP Request from apache through [[Modjs]].  This is the prime [[HTTPRequest]].&lt;br /&gt;
*[[HTTPResponse|response]]: The outgoing HTTP Response from this script back to the client through apache and [[Modjs]].  This is the prime [[HTTPResponse]].&lt;br /&gt;
&lt;br /&gt;
Constructors on the global object now:&lt;br /&gt;
*[[File|File API]]&lt;br /&gt;
*[[HTTPRequest]]&lt;br /&gt;
*[[HTTPResponse]]&lt;br /&gt;
*[[MailMesage]]&lt;br /&gt;
*[[MimeEntity]]&lt;br /&gt;
*[[MimeHeader]]&lt;br /&gt;
*[[MimeValue]]&lt;br /&gt;
*[[MimeProperty]]&lt;br /&gt;
*[[ProcessConnection]]&lt;br /&gt;
*[[TCPConnection]]&lt;br /&gt;
*[[DbConnection]]&lt;br /&gt;
*[[DbStatement]]&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=MimeHeader&amp;diff=2103</id>
		<title>MimeHeader</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=MimeHeader&amp;diff=2103"/>
		<updated>2009-01-23T05:12:35Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A MimeHeader object represents a single header in a MIME or HTTP message in a easier to use format for [[Modjs]] scripts.  Each header can have an array of MimeValue objects, which can have an array of MimeProperties. The true format of these are described in [[MIME]].&lt;br /&gt;
&lt;br /&gt;
To paraphrase, a true MIME header is a name:value[,value...] pair of form:&lt;br /&gt;
 header          := header-name  &amp;#039;:&amp;#039;  header-value  CRLF&lt;br /&gt;
 header-value    := values&lt;br /&gt;
 values          := (value-exp  &amp;#039;,&amp;#039;)*  value-exp&lt;br /&gt;
&lt;br /&gt;
Each value is of form:&lt;br /&gt;
 value-exp       := real-value  (&amp;#039;;&amp;#039;  property-exp)*&lt;br /&gt;
 real-value      := value-key [&amp;#039;=&amp;#039; value-value]&lt;br /&gt;
&lt;br /&gt;
And each property then is of form:&lt;br /&gt;
 property-exp    := property-key  [&amp;#039;=&amp;#039;  property-value]&lt;br /&gt;
&lt;br /&gt;
A new MimeHeader can be created using:&lt;br /&gt;
 header = new MimeHeader(name, array of MimeValue objects)&lt;br /&gt;
 header = new MimeHeader(name, raw value string)&lt;br /&gt;
&lt;br /&gt;
If the header cannot be created (if the objects passed in aren&amp;#039;t duckable to MimeValue, or the string isn&amp;#039;t valid header value formatted), an exception can be thrown:&lt;br /&gt;
 MimeHeaderException&lt;br /&gt;
&lt;br /&gt;
A new MimeValue can be created using:&lt;br /&gt;
 value = new MimeValue(raw value, array of MimeParameters)&lt;br /&gt;
 value = new MimeValue(value name, value content, array of MimeParameters)&lt;br /&gt;
 value = new MimeValue(raw value string)&lt;br /&gt;
&lt;br /&gt;
These could throw:&lt;br /&gt;
 MimeValueException&lt;br /&gt;
&lt;br /&gt;
A new MimeProperty can be created using:&lt;br /&gt;
 property = new MimeProperty(property name, property value)&lt;br /&gt;
&lt;br /&gt;
Once a header is created, it has these properties:&lt;br /&gt;
*name: The header name&lt;br /&gt;
*values: array of MimeValue objects&lt;br /&gt;
&lt;br /&gt;
The header has several methods:&lt;br /&gt;
 string = header.getName()&lt;br /&gt;
 array of MimeValues = header.getValueList()&lt;br /&gt;
 header.addValue(MimeValue)&lt;br /&gt;
 MimeValue = header.removeValue(index)&lt;br /&gt;
 MimeValue = header.getValue(index)&lt;br /&gt;
 string = header.toString()&lt;br /&gt;
 string = header.getValue(value name)&lt;br /&gt;
 string = header.getAllValues()&lt;br /&gt;
&lt;br /&gt;
The value has these properties:&lt;br /&gt;
*value: The value name, or &amp;quot;true&amp;quot; value&lt;br /&gt;
*content: the value content&lt;br /&gt;
*properties: array of parameter name/value pairs&lt;br /&gt;
&lt;br /&gt;
And these methods:&lt;br /&gt;
 string = value.getValueName()&lt;br /&gt;
 string = value.getValueContent()&lt;br /&gt;
 string = value.getValue()&lt;br /&gt;
 value.setValueContent(string)&lt;br /&gt;
 array of MimeParameters = value.getPropertyList()&lt;br /&gt;
 value.addParameter(MimeParameter)&lt;br /&gt;
 MimeParameter = value.removeParameter(index)&lt;br /&gt;
 MimeParameter = value.getParameter(index)&lt;br /&gt;
 string = value.toString()&lt;br /&gt;
 string = value.getParameter(parameter name)&lt;br /&gt;
&lt;br /&gt;
MimeParameters have these properties:&lt;br /&gt;
*name: the parameter name&lt;br /&gt;
*value: the parameter value&lt;br /&gt;
&lt;br /&gt;
And these methods:&lt;br /&gt;
 string = parm.getName()&lt;br /&gt;
 string = parm.getValue()&lt;br /&gt;
 parm.setValue(string)&lt;br /&gt;
 string = parm.toString()&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
	<entry>
		<id>http://sessrumnir.net/fernseher/index.php?title=MimeEntity&amp;diff=2102</id>
		<title>MimeEntity</title>
		<link rel="alternate" type="text/html" href="http://sessrumnir.net/fernseher/index.php?title=MimeEntity&amp;diff=2102"/>
		<updated>2009-01-23T05:11:06Z</updated>

		<summary type="html">&lt;p&gt;96.42.70.86: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;MimeEntity represents a standard [[MIME]]/HTTP entity, including headers and body.  For [[Modjs]], there is a MimeEntity in [[MailMessage]]s, [[HTTPRequest]]s, and [[HTTPResponse]]s, including the request that brought about the modjs script invocation, and the response that will be sent back.&lt;br /&gt;
&lt;br /&gt;
MimeEntitys can be created manually with:&lt;br /&gt;
 entity = new MimeEntity(array of [[MimeHeader]]s, body)&lt;br /&gt;
&lt;br /&gt;
If this doesn&amp;#039;t work for some reason, it could throw&lt;br /&gt;
 MimeEntityException&lt;br /&gt;
&lt;br /&gt;
Each MimeEntity has the following properties, which may be queried, but really shouldn&amp;#039;t be edited directly.&lt;br /&gt;
*headers: the array of [[MimeHeader]]s for this entity&lt;br /&gt;
*body: the raw body of this entity&lt;br /&gt;
*type: the major content type of this entity&lt;br /&gt;
*subtype: the subtype of this entity&lt;br /&gt;
*id: the content-id of this entity, if it has one&lt;br /&gt;
*boundary: the boundary string of this entity&lt;br /&gt;
*children: an array of MimeEntities representing the children of this entity, in the multipart and message types&lt;br /&gt;
*leader: In a multipart or message entity, the part of the body before the first boundary&lt;br /&gt;
*trailer: In a multipart or message entity, the part of the body after the last boundary&lt;br /&gt;
&lt;br /&gt;
The entity also has the following methods, which should be the primary method of modifying the entity if needed.&lt;br /&gt;
 string = entity.toString()&lt;br /&gt;
 string = entity.getContentType()&lt;br /&gt;
 string = entity.getBoundaryString(last?)&lt;br /&gt;
 entity.addHeader([[MimeHeader]] | array of [[MimeHeader]]s)&lt;br /&gt;
*adds the given headers, even if they already exist&lt;br /&gt;
 array of [[MimeHeader]]s = entity.getHeader(name)&lt;br /&gt;
*gets all headers of the given name&lt;br /&gt;
 string = entity.getHeaderValue(name)&lt;br /&gt;
*gets the value string (raw) of the first header with the given name&lt;br /&gt;
 entity.setHeader(name, value)&lt;br /&gt;
*changes the raw value string of the first header with the given name&lt;br /&gt;
 entity.clearBody()&lt;br /&gt;
 entity.setBody(string)&lt;br /&gt;
 entity.addToBody(string)&lt;br /&gt;
 entity.addMessageEntity(MimeEntity)&lt;br /&gt;
 entity.addMultipartEntity(MimeEntity | array of MimeEntitys)&lt;br /&gt;
 MimeEntity = entity.removeChildEntity(index)&lt;br /&gt;
 MimeEntity = entity.getChildEntity(index)&lt;br /&gt;
 MimeEntity = entity.getChildEntityById(id)&lt;/div&gt;</summary>
		<author><name>96.42.70.86</name></author>
	</entry>
</feed>