libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] feature request: get connection_timeout value from M


From: Vitaliy T
Subject: Re: [libmicrohttpd] feature request: get connection_timeout value from MHD_Connection structure
Date: Wed, 15 Mar 2017 17:06:35 +0300

On 15 March 2017 at 13:35, Vitaliy T <address@hidden> wrote:
> I suppose we may close the question in the next way. I will implement
> everything as I want, e.g. will made local patch to MHD and will test
> within some kind amount of time (weeks, months). And in the case if I
> would like see this feature in MHD-core I will send a patch.

Sorry, I have decided that's better make the patch right now than skip
it to better times.
The patch is below. It is a quite simple.

Do I have to create a test for it? If so, just tell me how you cooking tests.
Do I have to expand notes?
Do I have to change/fix something?

If nothing is required, let's close the question. I can easily to
forgot about it, I have to code billions lines :)


diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index c1461988..a91a1885 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -3140,6 +3140,21 @@ MHD_set_connection_option (struct
MHD_Connection *connection,


 /**
+ * Get a custom option for the given connection.
+ *
+ * @param connection what connection to get information about
+ * @param option option to get
+ * @param ... arguments to the option, depending on the option type
+ * @return #MHD_YES on success, #MHD_NO if setting the option failed
+ * @ingroup specialized
+ */
+_MHD_EXTERN int
+MHD_get_connection_option (struct MHD_Connection *connection,
+               enum MHD_CONNECTION_OPTION option,
+               ...);
+
+
+/**
  * Information about an MHD daemon.
  */
 union MHD_DaemonInfo
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f192a1bb..515a69d6 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3400,6 +3400,47 @@ MHD_set_connection_option (struct
MHD_Connection *connection,


 /**
+ * Get a custom option for the given connection.
+ *
+ * @param connection what connection to get information about
+ * @param option option to get
+ * @param ... arguments to the option, depending on the option type
+ * @return #MHD_YES on success, #MHD_NO if setting the option failed
+ * @ingroup specialized
+ */
+int
+MHD_get_connection_option (struct MHD_Connection *connection,
+               enum MHD_CONNECTION_OPTION option,
+               ...)
+{
+  va_list ap;
+  struct MHD_Daemon *daemon;
+  unsigned int *timeout_ptr;
+
+  daemon = connection->daemon;
+  switch (option)
+    {
+    case MHD_CONNECTION_OPTION_TIMEOUT:
+      va_start (ap, option);
+      timeout_ptr = va_arg (ap, unsigned int *);
+      if (timeout_ptr == NULL) {
+          va_end (ap);
+          return MHD_NO;
+      }
+      if (connection->connection_timeout != daemon->connection_timeout)
+          /* timeout was set by a user */
+          *timeout_ptr = connection->connection_timeout;
+      else
+          *timeout_ptr = daemon->connection_timeout;
+      va_end (ap);
+      return MHD_YES;
+    default:
+      return MHD_NO;
+    }
+}
+
+
+/**
  * Queue a response to be transmitted to the client (as soon as
  * possible but after #MHD_AccessHandlerCallback returns).
  *


-- 
With Best Regards,
Vitaliy V. Tokarev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]