How do I send form values (POST data)?

You can POST form data directly by using the Resource Interceptor system in Awesomium.

It's pretty simple, you would basically intercept the URL request before its sent to the server, change it into a POST request and add some extra POST data.

Here's an example using AwesomiumSharp:

First, hookup WebView.OnResourceRequest to your callback function.

webView.OnResourceRequest += OnRequest;

Then, define your callback function to handle the resource request:

    public ResourceResponse OnRequest(object sender, 
                             WebView.ResourceRequestEventArgs e)
    {
        if (e.request.getURL() == "http://url.goes.here/")
        {
            // Make this request into a POST request
            e.request.setMethod("POST");

            // Add our POST data in query-string format. Make sure that 
            // each value is url-encoded
            e.request.appendUploadBytes("name1=value1&name2=value2");

            // Add an extra header to tell the server that our POST data 
            // is url-encoded form data
            e.request.appendExtraHeader("Content-Type", 
                                "application/x-www-form-urlencoded");
        }

        // We return null because we want this request to be sent to the
        // server, we do not want to override the response.
        return null;
    }

If you wish to also submit "file" paths as part of your POST data, you will need to use "appendUploadFilePath" in conjunction with "appendUploadBytes", for example:

e.request.setMethod("POST");
e.request.appendUploadBytes("myFileFieldName=");
e.request.appendUploadFilePath("C:\\your\\file\\path\\here.txt");
e.request.appendExtraHeader("Content-Type", 
                                    "application/x-www-form-urlencoded");

Sending Multipart Form Data

A user in our forum, "ant", contributed the following code example for sending multipart form data using the C API of Awesomium:

wstring fieldName = L"pic_file";
wstring fileName = L"C:\\PATH\\TO\\file.jpg";

wstring CRLF = L"\r\n";
wstring boundary = L"-----boundary-----";
wstring method = L"POST";
wstring part;

part += L"--" + boundary + CRLF;
part += L"Content-Disposition: form-data; ";
part += L"name=\"" + fieldName + L"\"; ";
part += L"filename=\""+ fileName + L"\"" + CRLF;
part += L"Content-Type: application/octet-stream" + CRLF + CRLF;

awe_string *_method = awe_string_create_from_utf16(method.c_str(), method.length());
awe_resource_request_set_method(request, _method);
awe_string_destroy(_method);

awe_string *_part = awe_string_create_from_utf16(part.c_str(), part.length());
awe_resource_request_append_upload_bytes(request, _part);
awe_string_destroy(_part);

awe_string *_path = awe_string_create_from_utf16(fileName.c_str(), fileName.length());
awe_resource_request_append_upload_file_path(request, _path);
awe_string_destroy(_path);

part = CRLF + L"--" + boundary + L"--" + CRLF;
_part = awe_string_create_from_utf16(part.c_str(), part.length());
awe_resource_request_append_upload_bytes(request, _part);
awe_string_destroy(_part);

wstring headerName = "Content-Type";
wstring headerVal = "multipart/form-data; boundary=" + boundary;

awe_string *_headerName = awe_string_create_from_ascii(headerName.c_str(), headerName.length());
awe_string *_headerVal = awe_string_create_from_ascii(headerVal.c_str(), headerVal.length());
awe_resource_request_append_extra_header(request, _headerName, _headerVal);
awe_string_destroy(_headerName);
awe_string_destroy(_headerVal);