src: Implement per-frame DATA compression

Currently, nghttpd server only compresses files whose extensions are
one of .html, .js, .css and .txt.  nghttp advertises its support of
per-frame compression in SETTINGS frame.  To implement this feature,
we added 2 public API: nghttp2_session_get_remote_settings() and
nghttp2_gzip_inflate_finished().
This commit is contained in:
Tatsuhiro Tsujikawa
2014-05-02 23:34:57 +09:00
parent f3f9210dae
commit 9125499dd0
8 changed files with 328 additions and 33 deletions

View File

@@ -2080,6 +2080,14 @@ int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session* session,
int nghttp2_session_terminate_session(nghttp2_session *session,
nghttp2_error_code error_code);
/**
* @function
*
* Returns the value of SETTINGS |id| notified by a remote endpoint.
*/
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
nghttp2_settings_id id);
/**
* @function
*
@@ -2799,6 +2807,15 @@ int nghttp2_gzip_inflate(nghttp2_gzip *inflater,
uint8_t *out, size_t *outlen_ptr,
const uint8_t *in, size_t *inlen_ptr);
/**
* @function
*
* Returns nonzero if |inflater| sees the end of deflate stream.
* After this function returns nonzero, `nghttp2_gzip_inflate()` with
* |inflater| gets to return error.
*/
int nghttp2_gzip_inflate_finished(nghttp2_gzip *inflater);
/**
* @function
*

View File

@@ -89,3 +89,8 @@ int nghttp2_gzip_inflate(nghttp2_gzip *inflater,
return 0;
}
}
int nghttp2_gzip_inflate_finished(nghttp2_gzip *inflater)
{
return inflater->finished;
}

View File

@@ -5779,6 +5779,16 @@ int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session* session,
return nghttp2_session_next_data_read(session, stream);
}
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
nghttp2_settings_id id)
{
if(id > NGHTTP2_SETTINGS_MAX) {
return 0;
}
return session->remote_settings[id];
}
int nghttp2_session_upgrade(nghttp2_session *session,
const uint8_t *settings_payload,
size_t settings_payloadlen,