The declaration of the mg request info structure in mongoose.cs is not correct.
It currently reads:
/ This is "struct mg_request_info" from mongoose.h header file
[StructLayout(LayoutKind.Sequential)] public struct MongooseRequestInfo {
public string request_method;
public string uri;
public string post_data;
public string remote_user;
public long remote_ip;
public int remote_port;
public int post_data_len;
public int http_version_major;
public int http_version_minor;
public int status_code;
public int num_headers;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=64)] public MongooseHeader[]
http_headers;
};
Comparing with mongoose.h:
/*
* This structure contains full information about the HTTP request.
* It is passed to the user-specified callback function as a parameter.
*/
struct mg_request_info {
char *request_method; /* "GET", "POST", etc */
char *uri; /* Normalized URI */
char *query_string; /* \0 - terminated */
char *post_data; /* POST data buffer */
char *remote_user; /* Authenticated user */
long remote_ip; /* Client's IP address */
int remote_port; /* Client's port */
int post_data_len; /* POST buffer length */
int http_version_major;
int http_version_minor;
int status_code; /* HTTP status code */
int num_headers; /* Number of headers */
struct mg_header {
char *name; /* HTTP header name */
char *value; /* HTTP header value */
} http_headers[64]; /* Maximum 64 headers */
};
The query string member is clearly missing. I also believe that post_data
cannot be marshalled
as a null terminated string, so I think the struct should be declared:
// This is "struct mg_request_info" from mongoose.h header file
[StructLayout(LayoutKind.Sequential)] public struct MongooseRequestInfo {
public string request_method;
public string uri;
public string query_string
public IntPtr post_data;
public string remote_user;
public long remote_ip;
public int remote_port;
public int post_data_len;
public int http_version_major;
public int http_version_minor;
public int status_code;
public int num_headers;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=64)] public MongooseHeader[]
http_headers;
};
The members of Marshal can be used to construct a string from the post_data and
post_data_len
fields.
Original issue reported on code.google.com by jhmcale...@gmail.com on 9 Aug 2009 at 11:33
Original issue reported on code.google.com by
jhmcale...@gmail.com
on 9 Aug 2009 at 11:33