Then I run it. Network “GHI HotSpot” appears. I connect my laptop to this network, go to browser and send it the following: http://192.168.1.1/f.htm?f=567 or any other URL with query parameters.
The entire thing crashes with An unhandled exception of type ‘System.NullReferenceException’ occurred in GTM.GHIElectronics.WiFi_RN171.dll
We can reproduce the issue. A fix will be in the next SDK. However, if you want to apply the fix now, follow the steps in https://www.ghielectronics.com/docs/122/gadgeteer-driver-modification to modify the WiFi RN171 driver and replace the function _ParseHttpHeader in WiFiRN171_42.cs starting on line 1145 with the following:
private HttpRequest _ParseHttpHeader(string buffer)
{
HttpRequest request = new HttpRequest();
//Get the request type
if (buffer.IndexOf("GET") >= 0)
request.RequestType = HttpRequest.HttpRequestType.GET;
else if (buffer.IndexOf("POST") >= 0)
request.RequestType = HttpRequest.HttpRequestType.POST;
//Get the requested document
int start_index = buffer.IndexOf("/");
int end_index = start_index >= 0 ? buffer.IndexOf(" ", start_index) : -1;
if (start_index >= 0 && end_index > start_index)
{
int i = buffer.IndexOf("?");
if (i > 0)
{
string query = buffer.Substring(i + 1, end_index - (i + 1));
request.URL = buffer.Substring(start_index, i - start_index);
var paras = query.Split('=', '&');
for (int j = 0; j < paras.Length; j += 2)
request.QueryData[_UrlDecode(paras[j])] = _UrlDecode(paras[j + 1]);
}
else
{
request.URL = buffer.Substring(start_index, end_index - start_index);
}
//Shift the buffer forward
buffer = buffer.Substring(buffer.IndexOf("\r\n") + 2);
}
//Inflate the individual elements
int index = -1;
string line_buffer = "";
bool keep_check = true;
while ((index = buffer.IndexOf("\r\n")) >= 0)
{
//For POST headers, we need to determine the length of the post data
if (request.RequestType == HttpRequest.HttpRequestType.POST && keep_check)
{
line_buffer = buffer.Substring(0, index);
if (line_buffer.IndexOf("Content-Length:") == 0)
{
StringToInt(line_buffer.Substring(16), out request.PostLength);
//Once we have the content length, we no longer need to parse
//the individual lines
keep_check = false;
}
if (line_buffer.IndexOf(": ") > 0)
{
request.HeaderData[line_buffer.Substring(0, line_buffer.IndexOf(": "))]
=
line_buffer.Substring((line_buffer.IndexOf(": ") + 2));
}
}
else
{
line_buffer = buffer.Substring(0, index);
//Add the element
if (line_buffer.IndexOf(": ") > 0)
{
request.HeaderData[line_buffer.Substring(0, line_buffer.IndexOf(": "))]
=
line_buffer.Substring((line_buffer.IndexOf(": ") + 2));
}
line_buffer = "";
}
//Shift the buffer forward
buffer = buffer.Substring(index + 2);
}
return request;
}
Additionally, in HttpRequest.cs, replace the constructor on line 71 with
public HttpRequest()
{
HeaderData = new HttpHeaderList();
QueryData = new QueryDataList();
}