Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved utilities to mod_parrot_util, added request and input header re…
…trieval to input
- Loading branch information
Showing
8 changed files
with
83 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
|
||
|
||
function main[main](var request) { | ||
say("Hello, world!"); | ||
print("1 + 1 = ", 1 + 1); | ||
print("\n"); | ||
var request = getstdin().request(); | ||
for(string k in request) { | ||
say(sprintf("%s: %s", [k, request[k]])); | ||
} | ||
var headers = getstdin().headers(); | ||
for(string k in headers) { | ||
say(sprintf("%s: %s", [k, headers[k]])); | ||
} | ||
say(getstdin().readall()); | ||
|
||
getstdout().headers({ "X-Foo":"bar", "X-Quix": "quam"}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "mod_parrot.h" | ||
#define HASH_CLASS_NAME "Hash" | ||
|
||
|
||
Parrot_PMC mod_parrot_new_hash(Parrot_PMC interp) { | ||
Parrot_PMC classKey, classObj, hashObj; | ||
Parrot_String hashName; | ||
Parrot_api_string_import_ascii(interp, HASH_CLASS_NAME, &hashName); | ||
Parrot_api_pmc_box_string(interp, hashName, &classKey); | ||
Parrot_api_pmc_get_class(interp, classKey, &classObj); | ||
if(Parrot_api_pmc_new_from_class(interp, classObj, NULL, &hashObj)) | ||
return hashObj; | ||
return NULL; | ||
} | ||
|
||
void mod_parrot_hash_set(Parrot_PMC interp, Parrot_PMC hash, char * key, char * value) { | ||
Parrot_String keyString, valueString; | ||
Parrot_PMC valueObj; | ||
Parrot_api_string_import_ascii(interp, key, &keyString); | ||
Parrot_api_string_import_ascii(interp, value, &valueString); | ||
Parrot_api_pmc_box_string(interp, valueString, &valueObj); | ||
Parrot_api_pmc_set_keyed_string(interp, hash, keyString, valueObj); | ||
} |