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

Make 1XXTIMEOUT a request flag rather than a session flag: #143

Merged
merged 1 commit into from
Jan 29, 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
7 changes: 7 additions & 0 deletions doc/ref/reqflags.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
<literal>POST</literal></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NE_REQFLAG_1XXTIMEOUT</constant> (default on)</term>
<listitem>
<simpara>disable this flag to disable overall timeout
when reading interim (1xx) responses; </simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand Down
7 changes: 0 additions & 7 deletions doc/ref/sessflags.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@
improve interoperability with SharePoint</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NE_SESSFLAG_1XXTIMEOUT</constant> (default on)</term>
<listitem>
<simpara>disable this flag to disable overall timeout
when reading interim (1xx) responses; </simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand Down
14 changes: 8 additions & 6 deletions src/ne_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ ne_request *ne_request_create(ne_session *sess, const char *method,
req->flags[NE_REQFLAG_IDEMPOTENT] = 1;
/* Expect-100 default follows the corresponding session flag. */
req->flags[NE_REQFLAG_EXPECT100] = sess->flags[NE_SESSFLAG_EXPECT100];
/* 1xx timeouts default to on. */
req->flags[NE_REQFLAG_1XXTIMEOUT] = 1;

/* Add in the fixed headers */
req->headers = initial_request_headers(req);
Expand Down Expand Up @@ -1015,9 +1017,9 @@ static int read_status_line(ne_request *req, ne_status *status, int retry)
return 0;
}

#define INTERIM_TIMEOUT(sess_) \
(((sess_)->flags[NE_SESSFLAG_1XXTIMEOUT] && (sess_)->rdtimeout) \
? time(NULL) + (sess_)->rdtimeout : 0)
#define INTERIM_TIMEOUT(req_) \
(((req_)->flags[NE_REQFLAG_1XXTIMEOUT] && (req_)->session->rdtimeout) \
? time(NULL) + (req_)->session->rdtimeout : 0)

/* Send the request, and read the response Status-Line. Returns:
* NE_RETRY connection closed by server; persistent connection
Expand All @@ -1033,7 +1035,7 @@ static int send_request(ne_request *req, const ne_buffer *request)
ne_status *const status = &req->status;
int sentbody = 0; /* zero until body has been sent. */
int ret, retry; /* retry non-zero whilst the request should be retried */
time_t timeout = INTERIM_TIMEOUT(sess);
time_t timeout = INTERIM_TIMEOUT(req);
ssize_t sret;

/* Send the Request-Line and headers */
Expand Down Expand Up @@ -1085,9 +1087,9 @@ static int send_request(ne_request *req, const ne_buffer *request)
if ((ret = send_request_body(req, 0)) != NE_OK) break;
sentbody = 1;
/* Reset read timeout. */
timeout = INTERIM_TIMEOUT(sess);
timeout = INTERIM_TIMEOUT(req);
}
else if (sess->flags[NE_SESSFLAG_1XXTIMEOUT] && sess->rdtimeout
else if (req->flags[NE_REQFLAG_1XXTIMEOUT] && sess->rdtimeout
&& time(NULL) > timeout) {
NE_DEBUG(NE_DBG_HTTP, "[req] Timeout after %d\n", sess->rdtimeout);
return aborted(req, _("Timed out reading interim responses"), 0);
Expand Down
4 changes: 4 additions & 0 deletions src/ne_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ typedef enum ne_request_flag_e {
NE_REQFLAG_IDEMPOTENT, /* disable this flag if the request uses a
* non-idempotent method such as POST. */

NE_REQFLAG_1XXTIMEOUT, /* disable this flag to apply no overall
* timeout when reading interim
* responses. */

NE_REQFLAG_LAST /* enum sentinel value */
} ne_request_flag;

Expand Down
1 change: 0 additions & 1 deletion src/ne_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ ne_session *ne_session_create(const char *scheme,

/* Set flags which default to on: */
sess->flags[NE_SESSFLAG_PERSIST] = 1;
sess->flags[NE_SESSFLAG_1XXTIMEOUT] = 1;

#ifdef NE_ENABLE_AUTO_LIBPROXY
ne_session_system_proxy(sess, 0);
Expand Down
4 changes: 0 additions & 4 deletions src/ne_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ typedef enum ne_session_flag_e {
* to improve interoperability with
* SharePoint */

NE_SESSFLAG_1XXTIMEOUT, /* disable this flag to apply no overall
* timeout when reading interim
* responses. */

NE_SESSFLAG_LAST /* enum sentinel value */
} ne_session_flag;

Expand Down
Loading