Updated Spec.
Changes:
-
Moved files into the form as that is how that is pushed in if you are doing multiple files
-
Support multiple files of the same name
-
Support multiple headers of the same name
-
Support multiple form fields of the same name
-
Specified that the get function is just a helper method. I think obj.header.get(“content”) is cleaner IMO than HashMap<Text, [Text]>.ofList(“content”, myList); (And I can’t actually find ofList in the base library…is this something new @nomeata ?)
{
method: Text;
url: {
original: Text;
protocal: Text //http or https - may always be https?;
port: Nat16; //maybe always 443? What about local replica?
host: {
original: Text;
array: Array; // host split at the "."s
};
path: {
original: Text;
array: Array; // split path by “/” into an array that can be referenced;
};
query: {
original: Text; //everything after the ? and before an anchor
get: (Text) → ?Text; //helper function: pass in a key and get value. null if not present
hashMap: HashMap<Text, Text>;
keys: [Text]; //list of query keys
};
anchor: Text; //an anchor if available(after the #;}; headers: { original: Array<(Text, Text)>; get: (Text) -> ?[Text] //helper function: pass in a key and get values. null if not present hashMap: HashMap<Text, [Text]>; keys: [Text]; //list of header keys }; body: ?{ //Get requests won't have a body original: Blob size: Nat; //size of the body form: { //if the content-type is as specified at https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST, parse the form and populate the collection get: (Text) -> ?[Text] //helper function: pass in a key and get value. null if not present hashMap: HashMap<Text, [Text]>; keys: [Text]; //list of form keys; files: (Text) -> ?[Buffer<Nat8>]; //helper function returns the formdata as a byte array; null if the form entry does not exist }; text: () -> Text; //converts the Blob to plain text file: () -> ?Buffer<Nat8>; //if not formdata and only one file is provided it will be here. bytes: (start, end) -> Buffer<Nat8>;//helper function: return the specified bytes from the blob. };
};