Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature flags #169

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ Changes in release 0.34.0
* Interface changes:
- API and ABI backwards-compatible with 0.27.x and later
* New interfaces and features:
- ne_request.h: add ne_get_response_location()
- ne_redirect.h: support complete relative URI resolution
- ne_request.h: add ne_get_response_location(),
add ne_get_request_target()
- ne_redirect.h: adds relative URI resolution per RFC 9110
- ne_session.h: add NE_SESSFLAG_STRICT session flag
- ne_socket.h: add ne_iaddr_set_scope(), ne_iaddr_get_scope()
- ne_session.h: ne_session_create() accepts scoped IPv6
link-local literal addresses following the RFC 6874 syntax.
- ne_utils.h: add NE_FEATURE_GSSAPI, NE_FEATURE_LIBPXY feature flags
- HTTP strictness/compliance updated for RFC 9110/9112;
notably stricter in parsing header field line, chunked
transfer-encoding, status-line.
transfer-coding, status-line.
* Documentation & header updates for RFC 9110/9112.

Changes in release 0.33.0:
Expand Down
2 changes: 2 additions & 0 deletions doc/manual.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<!ENTITY refreqhdr SYSTEM "ref/reqhdr.xml">
<!ENTITY refresphdr SYSTEM "ref/resphdr.xml">
<!ENTITY refreqflags SYSTEM "ref/reqflags.xml">
<!ENTITY refred SYSTEM "ref/redir.xml">
<!ENTITY refstatus SYSTEM "ref/status.xml">
<!ENTITY refgetst SYSTEM "ref/getst.xml">
<!ENTITY refreqbody SYSTEM "ref/reqbody.xml">
Expand Down Expand Up @@ -190,6 +191,7 @@ ignoring the WebDAV support if desired.</para>
&refopts; <!-- ne_set_useragent -->
&refreqflags; <!-- ne_set_request_flag -->
&refreqbody; <!-- ne_set_request_body_buffer -->
&refred; <!-- ne_redirect_register -->
&refauth; <!-- ne_set_server_auth -->
&refshave; <!-- ne_shave -->
&refinit; <!-- ne_sock_init -->
Expand Down
12 changes: 12 additions & 0 deletions doc/ref/feat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
initialization &mdash; see <xref linkend="ne_sock_init"/></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NE_FEATURE_GSSAPI</constant></term>
<listitem>
<simpara>Indicates support for Negotiate authentication via GSSAPI</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NE_FEATURE_LIBPXY</constant></term>
<listitem>
<simpara>Indicates support for libproxy (<xref linkend="ne_session_system_proxy"/>)</simpara>
</listitem>
</varlistentry>
</variablelist>

</para>
Expand Down
69 changes: 69 additions & 0 deletions doc/ref/redir.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<refentry id="refred">

<refmeta>
<refentrytitle>ne_redirect_register</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>

<refnamediv>
<refname id="ne_redirect_register">ne_redirect_register</refname>
<refname id="ne_redirect_location">ne_redirect_location</refname>
<refpurpose>HTTP request redirect handling</refpurpose>
</refnamediv>

<refsynopsisdiv>

<funcsynopsis>

<funcsynopsisinfo>#include &lt;ne_redirect.h&gt;</funcsynopsisinfo>

<funcprototype>
<funcdef>void <function>ne_redirect_register</function></funcdef>
<paramdef>ne_session *<parameter>sess</parameter></paramdef>
</funcprototype>

<funcprototype>
<funcdef>const ne_uri *<function>ne_redirect_location</function></funcdef>
<paramdef>ne_session *<parameter>sess</parameter></paramdef>
</funcprototype>
</funcsynopsis>

</refsynopsisdiv>

<refsect1>
<title>Description</title>

<para>The <type>ne_redirect_register</type> function registers
redirect handling for the session. If a valid redirect (with
status code 3xx) response is processed, the request will fail
with the <literal>NE_REDIRECT</literal> error code. The
destination of the redirect can then be retrieved using
<function>ne_redirect_location</function>.</para>

<para>If a redirect was processed, the
<type>ne_redirect_location</type> function returns the
destination URI of the redirect.</para>

</refsect1>

<refsect1>
<title>Return value</title>

<para><function>ne_redirect_location</function> returns
<literal>NULL</literal> if no request has yet been processed,
if the current request was not a redirect, or if the
destination of the redirect could not be parsed or
resolved. Otherwise it returns a pointer to an
<type>ne_uri</type> object, which remains valid until another
request is created for the session.</para>

</refsect1>

<refsect1>
<title>See also</title>

<para><xref linkend="ne_session_create"/>.</para>

</refsect1>

</refentry>
6 changes: 6 additions & 0 deletions src/ne_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ int ne_has_support(int feature)
#endif
#ifdef HAVE_SSPI
case NE_FEATURE_SSPI:
#endif
#ifdef NE_HAVE_GSSAPI
case NE_FEATURE_GSSAPI:
#endif
#ifdef NE_HAVE_LIBPXY
case NE_FEATURE_LIBPXY:
#endif
return 1;
#endif /* NE_HAVE_* */
Expand Down
2 changes: 2 additions & 0 deletions src/ne_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ int ne_version_match(int major, int minor);
#define NE_FEATURE_TS_SSL (6) /* Thread-safe SSL/TLS support */
#define NE_FEATURE_I18N (7) /* i18n error message support */
#define NE_FEATURE_SSPI (8) /* NTLM/Negotiate authentication protocol via SSPI */
#define NE_FEATURE_GSSAPI (9) /* GSSAPI support. */
#define NE_FEATURE_LIBPXY (10) /* libproxy support. */

/* Returns non-zero if library is built with support for the given
* NE_FEATURE_* feature code 'code'. */
Expand Down
14 changes: 14 additions & 0 deletions test/util-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,20 @@ static int support(void)
#else
ONN("i18n SSL support advertised",
ne_has_support(NE_FEATURE_I18N));
#endif
#ifdef NE_HAVE_GSSAPI
ONN("GSSAPI support not advertised",
!ne_has_support(NE_FEATURE_GSSAPI));
#else
ONN("GSSAPI support advertised",
ne_has_support(NE_FEATURE_GSSAPI));
#endif
#ifdef NE_HAVE_LIBPXY
ONN("libproxy support not advertised",
!ne_has_support(NE_FEATURE_LIBPXY));
#else
ONN("libproxy support advertised",
ne_has_support(NE_FEATURE_LIBPXY));
#endif
return OK;
}
Expand Down
Loading