Skip to content

HTTP Set Channel Mode

Thomas Cherryhomes edited this page Dec 26, 2020 · 6 revisions

Description

Changes the channel mode on an HTTP connection. This is used so that you can change the behavior of the GET, PUT, and STATUS commands to retrieve and send different types of information required for a complete HTTP transaction, such as headers, and POST data.

There are four modes which can be selected, depending on the value of AUX2:

AUX2 Description
0 BODY
1 COLLECT HEADERS
2 GET HEADERS
3 SET HEADERS
4 SET POST DATA

AUX2 = BODY

Use this mode to retrieve the BODY of an HTTP document.

With this mode:

  • STATUS returns the number of bytes still to be read in the HTTP BODY.
  • READ will return the specified number of bytes from the HTTP BODY.
  • WRITE will write the specified number of bytes to the BODY (PUT mode only)

AUX2 = COLLECT HEADERS

Use this mode as the first step in retrieving headers from an HTTP response. Each header requested is written one line at a time, terminated by an ATASCII EOL ($9B). The #FujiNet will retrieve exactly the headers written in this mode, in the order in which they are written.

With this mode:

  • STATUS does not return anything meaningful, as it is a write only mode.
  • READ returns a WRITE MODE ONLY error, as it is a write only mode
  • WRITE will write the specified number of bytes to the COLLECT HEADERS routine. It is expected that each header be written, one at a time, terminated by a $9B. Do not write multiple ATASCII EOL terminated lines in one WRITE.

AUX2 = GET HEADERS

Causes the #FujiNet to retrieve the HTTP headers, and send each one, one line at a time, over the channel. This causes the HTTP transaction to occur.

With this mode:

  • STATUS returns the number of bytes for the next header value, including the ATASCII EOL.
  • READ returns the number of bytes requested of the next header value. It is expected that this match the value from STATUS.
  • WRITE will return a READ ONLY ERROR, as this is a read-only mode.

AUX2 = SET HEADERS

This mode changes channel behavior so that each WRITE sends a header key, and value in HTTP format, to be sent along with the HTTP transaction.

Set Header format

Key: Value<EOL>
  • Key is the name of the header
  • Value is the value to assign to the header key.

e.g.

Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l

NOTE: The single white space after Key: is mandatory.

With this mode:

  • STATUS does not return meaningful data, as it is a write-only mode.
  • READ returns a WRITE ONLY error, as tihs is a write-only mode.
  • WRITE will write the specified # of bytes as a header. The header must be in the format above. With one space after the Key:

Parameters

DCB Value
DDEVIC $71
DUNIT $01 - $04
DCOMND $4F 'O'
DSTATS $80
DBUF a 256 byte buffer containing N: devicespec
DTIMLO $0F
DBYT 256
DAUX1 N: AUX1 Values
DAUX2 N: AUX2 Values

Examples

CC65

static unsigned char hostname[256]="N:TCP://irata.online:8005/";

/**
 * io_init() - Set-up the I/O
 */
void io_init(void)
{
  OS.vprced=ih;
  PIA.pactl |= 1;
  // Establish connection
  OS.dcb.ddevic=0x71;
  OS.dcb.dunit=1;
  OS.dcb.dcomnd='O';
  OS.dcb.dstats=0x80;
  OS.dcb.dbuf=&hostname;
  OS.dcb.dtimlo=0x0f;
  OS.dcb.dbyt=256;
  OS.dcb.daux=0;
  siov();
}

See Also

Put other related command links here.

Clone this wiki locally