Maneesh P M
7d68926539
Drop usage of Reader from InternalServer::handle_meta
...
This is essentially a code move of meta handlers from using Reader
functions to directly using Archive.
2021-07-03 14:04:02 +05:30
Vertigo
8d39b2c4c1
Added content ZIM home button on 404
2021-06-17 12:51:27 +05:30
Veloman Yunkan
78083f1f4a
Moved OPDS templates under static/templates
2021-06-08 20:37:00 +04:00
Veloman Yunkan
e799f2ff1e
OPDSDumper::dumpOPDSFeed() works via mustache
...
This changes the output of `/catalog/search` as follows:
- Entire search query (rather than only the value of the `q` parameter)
is put in the <title> node.
- Search performed with an empty query presents itself as "All zims".
- The feed id remains stable for identical searches on the same
library.
2021-06-08 20:37:00 +04:00
Veloman Yunkan
312f2cb560
Moved handle_catalog_v2*() methods into a new file
2021-06-08 20:37:00 +04:00
Veloman Yunkan
f1797993af
Reused InternalServer::search_catalog()
2021-06-08 20:37:00 +04:00
Veloman Yunkan
f886c8c07b
Root url is normalized once in the constructor
2021-06-08 20:37:00 +04:00
Veloman Yunkan
9ca6bd006f
/catalog/v2/categories goes through OPDSDumper too
2021-06-08 20:37:00 +04:00
Veloman Yunkan
cdacc0caf1
/catalog/v2/entries going through OPDSDumper
...
OPDSDumper sensed threats to its job security, so it lobbied to be
involved in handling the /catalog/v2 endpoints, too.
2021-06-08 20:37:00 +04:00
Veloman Yunkan
dfad1c3815
/catalog/v2/searchdescription.xml
2021-06-08 20:37:00 +04:00
Veloman Yunkan
07252a127a
/catalog/v2/entries is also a search endpoint
2021-06-08 20:37:00 +04:00
Veloman Yunkan
b60e3ffb26
RequestContext::get_optional_param()
2021-06-08 20:37:00 +04:00
Veloman Yunkan
70d42aec98
A small simplification
2021-06-08 20:37:00 +04:00
Veloman Yunkan
4aa3c792aa
Extracted get_search_filter()
2021-06-08 20:37:00 +04:00
Veloman Yunkan
208dece7e3
Reordered several statements
...
Reordered several statements so that the next couple of commits are a
little simpler.
2021-06-08 20:37:00 +04:00
Veloman Yunkan
19b59fd72f
Serving /catalog/v2/entries
...
/catalog/v2/entries is intended to play the combined role of
/catalog/root.xml and /catalog/search of the old OPDS API. Currently,
the latter role is not yet implemented.
Implementation note: instead of tweaking and reusing
`OPDSDumper::dumpOPDSFeed()`, the generation of the OPDS feed is done via `mustache`
and a new template `static/catalog_v2_entries.xml`.
2021-06-08 20:37:00 +04:00
Veloman Yunkan
92c2de8d46
Enter InternalServer::m_library_id
...
The new field is intended to serve as a seed for generating semi-stable
OPDS feed ids that only need to change when the library is updated.
2021-06-08 20:37:00 +04:00
Veloman Yunkan
2e53b51696
Serving /catalog/v2/categories
2021-06-08 20:37:00 +04:00
Veloman Yunkan
3c3cf08a1a
Serving /catalog/v2/root.xml
...
Note: This commit somewhat relaxes validation of non variable
`<updated>` elements in the OPDS feed - the contents of any `<updated>`
element is replaced with the YYYY-MM-DDThh:mm:ssZ placeholder.
2021-06-08 16:03:43 +04:00
Veloman Yunkan
5b272ac49c
Fixed handling of /catalogBLABLA/root.xml & alike
...
Also removed an unneeded namespace qualifier.
2021-06-08 16:03:43 +04:00
Manan Jethwani
bb92f26b60
added filter functionality
2021-06-07 15:37:20 +02:00
Manan Jethwani
063bb8cd65
added dynamic and subset loading of zim-files in kiwix-serve
2021-06-01 19:33:42 +05:30
Maneesh P M
5567d8ca49
Replace std::vector<std::string> with SuggestionItem
...
Each sugestions used to be stored as vector of strings to hold various values
such as title, path etc inside them. With this commit, we use the new
dedicated class `SuggestionItem` to do the same.
2021-05-26 10:53:39 +02:00
Maneesh P M
56434de79e
Set label to title snippet if present
...
With openzim/libzim#545 we now support snippet generation of titles
which can be used as the display label on the ui for highlighted titles
via the "label" field.
The old version used plain title which is still available in the value
field.
2021-05-26 10:52:58 +02:00
Matthieu Gautier
2736a46cfe
Revert "Kiwix Serve welcome page dynamic and subset loading (OPDS based)"
2021-05-25 17:30:05 +02:00
Manan Jethwani
012973d14a
added dynamic and subset loading of zim-files in kiwix-serve
2021-05-25 02:41:12 +05:30
Emmanuel Engelhart
05cc3d015f
Insert root link only if html content
2021-05-14 14:49:28 +02:00
Veloman Yunkan
68189de162
/catalog/search handles out-of-bounds pagination
2021-05-10 11:25:06 +02:00
Maneesh P M
be6b58c6ad
Revert "added 204 code for empty return of search"
...
Returning status code 204 in case of an empty results doesn't show the
empty results page as described in #466 . Reverting the changes in #396
fixes the issue.
2021-05-09 10:47:18 +05:30
Manan Jethwani
965b9622c2
removed redirect to articles in search
2021-04-20 20:23:42 +05:30
Vertigo
611146aa37
Added Search Link for bad bookName/articleName on 404
2021-04-12 21:31:47 +05:30
Manan Jethwani
5cb276a933
adding kind and path attributes to suggest response object and using it in autocomplete
2021-04-07 21:04:33 +05:30
Manan Jethwani
7872734f44
changed method of injecting root link
2021-03-24 14:17:58 +05:30
Manan Jethwani
c557bb271b
injecting root link directly and renamed head_part to head_taskbar
2021-03-24 02:10:16 +05:30
Manan Jethwani
93264f7409
added root functionality for block external link feature
2021-03-23 03:17:14 +05:30
Veloman Yunkan
e55bf514e8
Dedicated 'category' parameter in catalog search
2021-03-17 14:10:57 +04:00
Veloman Yunkan
80d4f7e349
Extracted InternalServer::search_catalog()
2021-03-17 14:10:57 +04:00
Matthieu Gautier
3fd1310008
Use c++11 std::thread instead of pthread.
2021-01-26 17:53:25 +01:00
Emmanuel Engelhart
84895c4036
Better </head> detection regex
2021-01-18 13:16:56 +01:00
Emmanuel Engelhart
a8bf9dd5b4
Better Kiwix Serve Taskbar insertion (after charset definition)
2021-01-18 11:18:53 +01:00
Emmanuel Engelhart
a61c94ef10
Add GPLv3 header
2021-01-18 10:54:33 +01:00
Emmanuel Engelhart
8c43fd8d36
Fix taskbar insertion in case of '<head>' attributes
2021-01-11 14:37:19 +01:00
Steve Wills
6900b4e506
fix build on FreeBSD
...
With this header, sockaddr_in and INADDR_ANY are not defined
2020-12-07 09:38:46 -05:00
Matthieu Gautier
1a5a2e7a8e
Adapt kiwix-lib to the new libzim api.
2020-12-02 12:16:48 +01:00
Matthieu Gautier
6f0d3003ac
Remove `m_compress` member.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
ee17b0739a
Fix compilation on CI native dyn.
...
On the CI, the native_dyn docker image is setup with a packaged version
on libmicrohttpd for which `MHD_HTTP_RANGE_NOT_SATISFIABLE` is not
defined.
When the CI will be fixed, we can revert this commit.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
47436f7bdd
Move some header setting in response's constructors.
...
It make easier to understand what is somehow constant and what depends
of the context.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
3352c95314
Remove the `RedirectResponse` and use a basic `Response` with header.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
77123ac74c
Move the adding of 304 headers in 304 factory.
...
This avoid us to create a ContentResponse just to have some correct
headers.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
9078f0ac6e
Remove `ResponseMode`.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
8d6567d067
Create a utility builder for 416 response.
...
Also add a map in the response to store specific headers.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
6d5cddca12
Fix android compilation
...
Android clang complains about the fact it cannot move the
`std::unique_ptr<ContentResponse>` into a `std::unique_ptr<Response>&&`
(for the implicit `std::unique_ptr<Response>` constructor).
Let's help him a bit.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
a3939e9a05
Move all the content code in the ContentResponse.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
eee621d15b
Move small utilities method to create response in Response class.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
7b2ee37437
Move the entry response to its own class.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
f014fb2895
Introduce a ContentResponse.
...
This is only an "interface" for now as other type of response (entry) may
be "transformed" to a ContentResponse.
We cannot move all the code in the class.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
1011d1ff0b
Move the redirection response in its own class.
...
The redirection is the easiest to move, let's start with this one.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
9e351b279e
Remove `get_default_response` in favor of a static Response method.
...
We want to build different kind of response depending of the context.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
a0bdc0821c
Move internalServer code into its own source files.
2020-08-13 11:16:41 +02:00
Matthieu Gautier
87b5adcaf4
Make the response responsible to detect if we must introduce taskbar.
...
The response detect if taskbar must be added depending of the mimetype.
Now, `set_taskbar` can be call unconditionally
(no need to check for the mimetype)
And we don't need to call set_taskbar if we have no information to set.
2020-08-11 18:27:54 +02:00
renaud gaudin
3f25a3d005
Fixed #391 : prevent taskbar and blocker at article level
...
Some HTML articles are meant to be displayed through a viewer. In this case,
we know we don't want the server to inject the taskbar nor the link blocker
because the content is not a user-ready web page but a partial element of it.
Such articles still need to be `text/html` to be parsed properly by browsers.
This changes the way we decide to display the tasbar or not.
Previously, we were adding it to every article with a MIME __starting with__ `text/html`.
Now, we're additionally preventing it on `text/html` MIME if there is a `;raw=true` string inside.
This leaves articles with MIME `text/html;raw=true` (warc2zim convention) outside
of the taskbar target.
For similar reasons, the external-link blocker is set to apply to the same set of articles.
Previously, it was applied to all articles which was an (unoticable) mistake.
2020-08-07 09:26:24 +02:00
Veloman Yunkan
3d425f44de
Request header case is ignored
...
Originally reported against case sensitivity of the Range header
(see issue #387 ), this fix applies to all request headers (since
according to RFC 7230 all header fields are case-insensitive, see
https://tools.ietf.org/html/rfc7230#section-3.2 ). However, a
corresponding unit-test was added only for the Range header.
2020-07-30 16:01:51 +02:00
Kelson
cf8e8b94eb
Fix compilation with libmicrohttpd v0.97.1
2020-07-08 14:42:46 +02:00
Matthieu Gautier
ff605873ed
Include missing `algorithm` header.
...
`min` and `max` functions are defined here.
2020-06-10 15:27:51 +02:00
Veloman Yunkan
05ef5d5f51
Assertion in ByteRange allows 0-sized content
...
The assertion in the ByteRange constructor was written under the assumption that the content must have non-zero size. Now it allows that corner case.
2020-06-02 21:53:47 +04:00
Veloman Yunkan
f52b220d01
Dropped RequestContext::has_range()
2020-05-26 14:10:26 +04:00
Veloman Yunkan
50a850f3a9
Fixed a comment
2020-05-26 14:04:18 +04:00
Veloman Yunkan
886ae17274
Fixed a CodeFactor issue
2020-05-26 13:59:47 +04:00
Veloman Yunkan
85d6daabac
Rolled back minor unneeded changes
2020-05-26 13:10:50 +04:00
Veloman Yunkan
5f1918d005
Split a long line
2020-05-26 13:04:03 +04:00
Veloman Yunkan
16bd79fa1b
Final clean-up of byte_range.{h,cpp}
2020-05-26 12:50:08 +04:00
Veloman Yunkan
c2ebdefe8d
Handling of unsatisfiable ranges
2020-05-26 02:11:26 +04:00
Veloman Yunkan
37032892a4
Fixed compilation error under win32_*
...
ERROR is a macro under Windows
2020-05-26 01:58:17 +04:00
Veloman Yunkan
6b43438b74
Fixed compilation error under native_dyn
...
MHD_HTTP_RANGE_NOT_SATISFIABLE is not defined in the older version of
libmicrohttpd (that is used under CI/Linux native_dyn).
2020-05-26 01:54:36 +04:00
Veloman Yunkan
7301bf89bb
Some refactoring of byte-range parsing
2020-05-26 01:50:29 +04:00
Veloman Yunkan
ff23b28e7c
Removed unnecessary qualifier
2020-05-26 01:41:37 +04:00
Veloman Yunkan
931e95f391
Invalid byte ranges result in 416 responses
2020-05-26 01:40:07 +04:00
Veloman Yunkan
f7571b5b69
Content-Range header is set only for partial content
2020-05-25 17:42:18 +04:00
Veloman Yunkan
801ad18a89
ByteRange::resolve()
2020-05-25 17:27:35 +04:00
Veloman Yunkan
67a347c0c4
Moved byte-range parsing to byte_range.cpp
2020-05-25 17:21:10 +04:00
Veloman Yunkan
693905eb68
Default constructed ByteRange is a full range
2020-05-25 17:17:56 +04:00
Veloman Yunkan
f3e79c6b4c
Introduced src/server/byte_range.cpp
2020-05-25 16:43:44 +04:00
Veloman Yunkan
52f207eaa6
Support for single-ended byte ranges
2020-05-25 16:37:01 +04:00
Veloman Yunkan
67294217a8
ByteRange::Kind
2020-05-25 16:23:44 +04:00
Veloman Yunkan
d111a40ce8
Response::m_byteRange
2020-05-23 20:35:22 +04:00
Veloman Yunkan
0c5bb3fcfe
Moved ByteRange to a header file of its own
2020-05-23 20:08:53 +04:00
Veloman Yunkan
3fba8c20a0
Converted RequestContext::ByteRange to a class
...
Also renamed the `range_pair` data member of `RequestContext` to `byteRange_`
2020-05-23 19:59:47 +04:00
Veloman Yunkan
54db6049b7
Byte-range parsing not exposed in the header file
2020-05-23 18:58:19 +04:00
Veloman Yunkan
81c38d6b2b
parse_byte_range() without side-effects
2020-05-23 18:53:16 +04:00
Veloman Yunkan
e6a86c02ae
Got rid of RequestContext::accept_range
2020-05-23 17:15:42 +04:00
Veloman Yunkan
a0f7f32570
Re-ordered function definitions
2020-05-23 17:11:26 +04:00
Veloman Yunkan
c39fce8839
RequestContext::parse_byte_range()
2020-05-23 17:09:51 +04:00
Veloman Yunkan
de37489c53
Range header starts with a unit spec
...
After this commit valid ranges of the form "bytes=firstbyte-lastbyte" should
be handled correctly.
2020-05-22 17:17:31 +04:00
Veloman Yunkan
2a35a86de6
Fixed the size value used creating a response
...
In case of a partial response the size of the response is different
from the served entry size.
2020-05-22 16:49:35 +04:00
Veloman Yunkan
0a30a77c08
Handling of out of bound byte ranges
2020-05-22 16:46:38 +04:00
Veloman Yunkan
1a99bacfe3
Byte ranges are inclusive
...
The second component of a byte range, if present, designates the
index of the last byte to be included in the partial response.
2020-05-22 16:30:43 +04:00
Kelson
94c2ab4395
Add two OPDS related mime-types to compress for HTTP
2020-05-18 08:19:51 +02:00
Veloman Yunkan
5f0a9d0b08
Added a comment clarifying a non-obvious case
2020-05-15 15:17:04 +04:00
Veloman Yunkan
54f5dbbd35
Handling of If-None-Match conditional requests
2020-05-14 17:01:22 +04:00
Veloman Yunkan
95a5cde359
ETags are set in the response as needed
...
Also added server-unit tests related to ETags in the response.
2020-05-14 17:01:22 +04:00