Gwan C#, how to get HTTP headers?

本秂侑毒 提交于 2019-12-23 19:04:56

问题


I need it for rewriting url, to know which friendly url I am processing. For User-Agent and other stuff.

EDIT:

public class Gwan
{
    [MethodImplAttribute(MethodImplOptions.InternalCall)]
    extern public static long getEnv(string arg, int name);
}

Gwan.xbufCat(Gwan.getReply(args[0]), Gwan.getEnv(args[0], 3).ToString());

Unhandled Exception: System.MissingMethodException: Cannot find the requested method. at (wrapper managed-to-native) Gwan:getEnv (string,int)

What am I doing wrong?

I guess on your end you need to put something like:

mono_add_internal_call ("Gwan::getEnv", get_env);

Dll in /cs folder where gwan_api also is not Loaded


回答1:


Like for Java, G-WAN created some wrappers for the G-WAN C API. In both cases (Java and C#), these wrappers can be found under the gwan/libraries/cs directory.

Currently, the C# wrappers are:

// gwan_api.cs: exported G-WAN API calls for .NET C# servlets
using System;
using System.Runtime.CompilerServices;

public class Gwan
{
    [MethodImplAttribute(MethodImplOptions.InternalCall)]
    extern public static long getReply(string env);

    [MethodImplAttribute(MethodImplOptions.InternalCall)]
    extern public static void xbufCat(long reply, string mono_reply);

   [MethodImplAttribute(MethodImplOptions.InternalCall)]
   extern public static long cycles64();

   [MethodImplAttribute(MethodImplOptions.InternalCall)]
   extern public static long getNs   ();

   [MethodImplAttribute(MethodImplOptions.InternalCall)]
   extern public static long getUs   ();

   [MethodImplAttribute(MethodImplOptions.InternalCall)]
   extern public static long getMs   ();

   [MethodImplAttribute(MethodImplOptions.InternalCall)]
   extern public static void logErr  (long env, String msg);

   [MethodImplAttribute(MethodImplOptions.InternalCall)]
   extern public static void report  (long reply, int html_format);
}

But you can freely extend this file by adding more wrappers, either for the G-WAN C API, or for third-party C libraries loaded by your G-WAN scripts.

Hope this helps.


EDIT

You must implement the C# wrappers for any new G-WAN API (or external function) you want to support from your C# scripts.

The include file listed above is a mere list (not implementation).

Please refer to the Mono documentation for more details - or drop us a line at G-WAN if you want to sponsor the features you need.




回答2:


I think you will have to look on their website for support information or experiment with the code to output the headers, try outputting them into a messagebox.show(headersvariable); to begin with

http://gwan.com/developers#tab3

REQUEST_LEN, // int REQUEST_LEN // strlen(REQUEST); with headers 
HTTP_HEADERS, // struct *http_t; // see struct http_t above
HEAD_XBUF, // xbuf_t*HEAD_XBUF; // response HTTP headers(), if any 


来源:https://stackoverflow.com/questions/26323412/gwan-c-how-to-get-http-headers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!