Metamerge logo
Search

Advanced Search
*
*
*
* HOME DOCUMENTS & RESOURCES DOWNLOADS EARLY TECH ACCESS SUPPORT FAQ KNOWN ISSUES OLD VERSIONS
*

 

HTTP Parser

Overview

The HTTP Parser interprets a byte stream according to the HTTP protocol specification. This Parser is used by the  HTTP Client Connector version 2 and by HTTP Server Connector V2.

Configuration

The Parser has the following parameters:

Parameter

Description

parserType com.architech.parser.rspHTTPParser
headersAsProperties If set,  the header values will be get/set as Properties, otherwise the header values will be read/returned as Attributes. See below for a list of possible Attributes/Properties.
clientMode If set, the Parser operates in client mode, otherwise it is in server mode.

Attributes/Properties

When constructing a page, depending of the value of headersAsProperties, the parser will use these Attributes/Properties where relevant, to construct the header.. When reading a page, the parser will parse the header to fill in these Attibutes/Properties where possible. 

Attribute/Property Description
http.method The HTTP method when sending this information in client mode Default is "GET". This Attribute/Property is returned  in server mode. See http://www.w3.org/Protocols/HTTP/Methods.html for more information about HTTP methods.
http.url The URL to use. This Attribute/Property is mandatory in client mode
http.content-type The content type for the returned http.body (if any). If this is set to "application/x-www-form-urlencoded", the http.body will also be parsed for more headers. The default value when writing (when http.body contains something), is "text/plain".
http.responseCode The HTTP response code as an Integer object. Read in client mode.
200 OK    ---> 200. 
http.responseMsg The HTTP response message as a String object. Read in client mode.
200 OK    ---> OK
http.content-encoding The encoding of the returned http.body (if any)
http.content-length The number of bytes in http.body. This Property/Attribute is returned when reading, and ignored when writing (it is recomputed by the parser).
http.body When reading, depending of the content-type of the data, this object is an instance of java.lang.StringBuffer, a char[] or a byte[] that contains the returned body.  When the content is a StringBuffer, you can use code like this:
var body = conn.getObject ("http.body");
task.logmsg ("Returned text: " + body.toString() );
Look at Binary values in Scripting for how to handle a char[] or byte[].

When writing, http.body should contain either an instance of java.io.File, in which case that file will be used as the body, or some text that will be used as the body. 

http.redirect When this Attribute/Propery has a value, and we are writing and in server mode, just send a redirect message pointing to the value of this Attribute/Propery.
http.status Used when writing in server mode. Default is "OK". Interesting values are:
"OK" or "200 OK"- Return a "200 OK" response.
"FORBIDDEN" or "401 Forbidden"- Ask for authentication using the http.auth-realm Attribute/Property
"NOT FOUND" or  "404 File Not Found" - Return a 404 File Not Found response
http.auth-realm Used when requesting additional authentication. Default value is "metamerge-integrator".
http.authorization Contains the authorization read in server mode. It is probably easier to use http.remote_user and http.remote_pass.
http.remote_user The Username from the other end when reading in server mode, or the username to use when writing in client mode.
http.remote_pass The Password from the other end when reading in server mode, or the password to use when writing in client mode.
http.base The base URL. Returned when reading in server mode.
http.qs.* Parts of the query string when reading in server mode. The key is the part of name after "http.qs.". The value is contained in the Attribute/Property.
http.* All other Attributes/Properties beginning with "http.", will be used to generate a header-line when writing. When reading, headers are put into Attributes/Properties with a name beginning with "http.", and continuing with the name of the header.

See Also

HTTP Client Connector Version 2, HTTP Server Connector V2
 
*
  Metamerge Integrator version 4.6 ©Copyright Metamerge AS 2000-2002 Last edited 2002-06-10 contact us