Commit graph

5074 commits

Author SHA1 Message Date
Ashod Nakashian
a68c33477d nb: support inserting image
Change-Id: I6ef11634bbda7e3ecdc467ce10727c8573caef8d
2017-03-10 10:47:41 +01:00
Ashod Nakashian
fa0771921d nb: enable testCloseAfterClose
Change-Id: I4150c547c3859e22c6628cd8d65e470b71d8cad4
2017-03-10 10:47:41 +01:00
Ashod Nakashian
f26e64fb54 nb: shutdown on reaching connection or document limit
Change-Id: I5eedaf780ed00804d93c362e83ac4fcfd5d057b1
2017-03-10 10:47:41 +01:00
Ashod Nakashian
b7e94d03ea nb: websocket closing handshake
Change-Id: I45a6f2e680349fa2f77c20bb8f783093b9e1f212
2017-03-10 10:47:41 +01:00
Ashod Nakashian
28b3813249 nb: clear the input buffer only on success
With multipart streams the parsing isn't
done until all parts are in. We will need
to reparse the header when more data comes in
until we can parse all parts. Otherwise we
end up removing the header and losing it
when we can't find all parts in the body.

This fixes convert-to requests.

Change-Id: Ic1d5ccbd00fd6763eb91fdda35177f6df847f100
2017-03-10 10:47:41 +01:00
Ashod Nakashian
4abf706af6 nb: websocket shutdown support
Change-Id: I2fcab98e9725eca86d097f34236889fdf9289c47
2017-03-10 10:47:41 +01:00
Ashod Nakashian
88bbc303dc nb: unittest improvements
Change-Id: Ife4ed343d54137f254077d4f194157120cf82bad
2017-03-10 10:47:41 +01:00
Ashod Nakashian
27452ec98c nb: support WS shutdown
Change-Id: I08084abb25e494384235260dd1df83adc5e3a624
2017-03-10 10:47:41 +01:00
Ashod Nakashian
f9197ff020 nb: separate sendMessage and sendFrame
There are other types of frames than application
data.

Also a message can be composed of multiple frames.

Change-Id: Ia97349553b61ae05fa78854222808eaa43386c0e
2017-03-10 10:47:41 +01:00
Ashod Nakashian
17fc91e220 nb: process POST requests
These are really GET requests that aren't
WebSocket upgrade. Should rename to something
less misleading.

Re-enabled testSlideShow which depended on this.

Change-Id: I52b7f67b650fcdcbae7c2bff020b756099263141
2017-03-10 10:47:41 +01:00
Ashod Nakashian
9d72496038 nb: prefix large WS with nextmessage
Change-Id: Ie6583c93ada9cff8aa50137431b5c2c5f7b39d97
2017-03-10 10:47:41 +01:00
Ashod Nakashian
4b36fc9716 nb: send the WS upgrade response separate from later frames
Apparently if we don't send immediately after the upgrade
the first frame doesn't get parsed as WebSocket (at least
in Poco).

Change-Id: Ieb30afae1423d8352d81c79af568947d10fca1e6
2017-03-10 10:47:41 +01:00
Ashod Nakashian
c845890630 nb: log the test name where possible
Helps troubleshoot failed tests faster.

Change-Id: I12172bcdd46403b902bf440b919916263cb1a02b
2017-03-10 10:47:41 +01:00
Michael Meeks
3df5061a6b Wait for more data pleasantly if we fail to parse HTTP header. 2017-03-10 10:47:41 +01:00
Michael Meeks
184dcfa96e Ctrl-c should really terminate this if you keep going. 2017-03-10 10:47:41 +01:00
Ashod Nakashian
f08d9c9ec1 nb: handle bad requests with 400 response
Change-Id: I15ecc06a933a88f5ccdd0acfd16aac8b357f29df
2017-03-10 10:47:41 +01:00
Ashod Nakashian
ccdb1bcc6e nb: proper POST body processing
Change-Id: Ic37094e50979e14d2862ae32088295b42d9c4931
2017-03-10 10:47:41 +01:00
Ashod Nakashian
0c19d81fee nb: read the socket on accept
It's necessary to do the SSL handshake
and to get the request (if we get there)
on accepting so by the time we poll we know
what SSL needs to do next. No reason to
read on first poll when we should be
expecting a request upon connection anyway.

Change-Id: I8eecaad5f8450075d45e487702972418cad125bc
2017-03-10 10:47:41 +01:00
Ashod Nakashian
72669bf929 nb: logging
Change-Id: Ia67f746a6c71b4753d04b92472eddf1614c0d337
2017-03-10 10:47:41 +01:00
Ashod Nakashian
57235943c0 nb: ignore empty payloads
When the socket is closed the last WS frame
will not have any payload, just a frame.
In this case the socket should still fire
handleMessage so this frame could trigger
application logic, however in this case
ClientSession has nothing to do, so we skip it.

Change-Id: Ia2b13026e31460ffceb8f9d9cfa39d36fbc57146
2017-03-10 10:47:41 +01:00
Michael Meeks
aa0a85c16d Add debug, and set the 'fin' bit on messages as we send them. 2017-03-10 10:47:41 +01:00
Ashod Nakashian
df45db9da2 nb: shutdown socket after file-serving
Change-Id: Ibe0b33f371d46e62637f570265fcdf9c8bf60b2d
2017-03-10 10:47:41 +01:00
Ashod Nakashian
2f2ba870b3 nb: handle socket poll exceptions and remove socket
Change-Id: Ibdee316f102d6606c38470e5ccacd2a7bd7ea7ce
2017-03-10 10:47:41 +01:00
Ashod Nakashian
925934d09d nb: set the Date in http header
Change-Id: I71e3388c1f204135c6dc72ad27890bffe53792b3
2017-03-10 10:47:41 +01:00
Ashod Nakashian
0759d1afbc nb: http error cases in file server
Change-Id: I81b0ef3f080ba61836d99fbdde0fb94e1a44a625
2017-03-10 10:47:41 +01:00
Ashod Nakashian
1bb29282f1 nb: serve files using non-blocking sockets
Change-Id: I254288980f72f197d29b7b57ec9c88a01a5a1d03
2017-03-10 10:47:40 +01:00
Ashod Nakashian
ba8d3c8eb1 nb: log requests as debug and not error
Change-Id: Ic3ec3257f98c80e959c9d980fe6b1d8d6f40f604
2017-03-10 10:47:40 +01:00
Ashod Nakashian
784dd41eae nb: simplify WS sendMessage interface
No need to construct vector<char> where
a simple char*/size_t suffice.

Change-Id: Ic70ad65a2078a1f653695504a79532f7831d88be
2017-03-10 10:47:40 +01:00
Ashod Nakashian
70b5aad1a6 nb: for now disable the broken WS tests
Change-Id: I2fdb5ce976f0c29a89fbcaa4e25a14c73644dd83
2017-03-10 10:47:40 +01:00
Ashod Nakashian
c8619bed1f nb: respond with HTTP 200 on root
Change-Id: Icfcf8d79d5b6370b7965584e89e9006d7bd451b3
2017-03-10 10:47:40 +01:00
Ashod Nakashian
de92b1627e nb: send files over HTTP
Change-Id: I346e97cd19a8dbbdee493d23b89c390ea6e3c948
2017-03-10 10:47:40 +01:00
Ashod Nakashian
0d9bbac18c nb: serve wopi discovery XML
Change-Id: I7bb4910f948e8b4e89f3bbdf2a62a8b1540eef2f
2017-03-10 10:47:40 +01:00
Ashod Nakashian
9bf8720d2b nb: SSL socket support in wsd
Change-Id: I21e8b2d04caf7da872fe07b4950b02a8c52a3552
2017-03-10 10:47:40 +01:00
Ashod Nakashian
d488efd3b7 nb: move openssl-specific struct to avoid conflicts
Change-Id: I4cf4ceb5b9ae1748f5087d4884dc40c280f5a00c
2017-03-10 10:47:40 +01:00
Ashod Nakashian
e184a371a0 nb: write socket buffer to socket safely
Since a socket client can push data into
the socket in a different thread than the one
polling (indeed that's the only possible scenario),
the write buffer must be protected by a lock.

On the other hand, the read buffer is always
invoked from a single thread, the polling. So
it is perfectly safe without locks.

Change-Id: Id0b6a01f8e96124a299810f0aacab9cecd1ff979
2017-03-10 10:47:40 +01:00
Ashod Nakashian
c2444bba9e nb: more informative WebSocket message logging
Change-Id: I3229a98dcefc115fe1b730b57fcac71aeb868aad
2017-03-10 10:47:40 +01:00
Ashod Nakashian
fdc658845d nb: always call onDisconnected when socket is closed
Change-Id: Ib42354fd1e8c68e78c6e5c501802a0e145b39260
2017-03-10 10:47:40 +01:00
Ashod Nakashian
2b4e7bd067 nb: SocketHandlerInterface must hold weak_ptr to Socket
Because the socket can be freed while a separate
thread is sending data via the handler, we must
have a locked reference to the socket instance
in the handler.

Change-Id: Iefad3fc2b147f96b8d538d9edd7cac3fce25b5bf
2017-03-10 10:47:40 +01:00
Ashod Nakashian
3b68944226 nb: socket logging
Change-Id: I1ee80eea39b7e910acf4ef0d12ea8aa436937041
2017-03-10 10:47:40 +01:00
Ashod Nakashian
46ccfb165f nb: testLoad -> testLoadSimple
Change-Id: Ief4292f3c7bf8cd6866a83518998d250ebc03355
2017-03-10 10:47:40 +01:00
Ashod Nakashian
576bd3ab4d nb: write WS frame to socket
We need to flush writes to socket as soon as
ready to either send or, if buffers are full,
to poll for write.

With WebSocket we do this after writing a frame.

Change-Id: I1bc276e678375a84079e69624414a16271f25351
2017-03-10 10:47:40 +01:00
Ashod Nakashian
9efb14def7 nb: pass the WS frame type explicitly
Change-Id: Iaf4d832af4313b629701c7f07832dcaaf3e53c20
2017-03-10 10:47:40 +01:00
Ashod Nakashian
32b7d5ceee nb: WebSocketSender used to send back loading progress
Change-Id: I3b09c44c4d64db39217d364ebff0a647a82457f4
2017-03-10 10:47:40 +01:00
Ashod Nakashian
5b944cf99b nb: don't own your owner
Change-Id: Ia74dbd3441b8b1f682091ba3d973dd33b2599309
2017-03-10 10:47:40 +01:00
Ashod Nakashian
66bc78aa33 nb: differentiate between incomplete request and processing failure
Change-Id: Ieffae987c9008a92d8040f0c4315afe6625715c4
2017-03-10 10:47:40 +01:00
Ashod Nakashian
221059cd6b nb: move WebSocket upgrade to the ClientRequestDispatcher
Change-Id: Id11b139563a55e50d3f7e216e2231d79e07015b3
2017-03-10 10:47:40 +01:00
Ashod Nakashian
73f9001004 nb: remove HTTP handling from WebSocketHandler
WebSocketHandler now supports upgrading given
the original HTTP header.

Change-Id: Ifb3b8fee9aef8015548a625bbb88e75f4e97255f
2017-03-10 10:47:40 +01:00
Ashod Nakashian
6b28ea0c12 nb: autosave document on client disconnection
Change-Id: Ic75a9796a1cca0bf919fb2dcbe24c504e447e7f1
2017-03-10 10:47:40 +01:00
Ashod Nakashian
3b3b61af30 nb: create and assign ClientSession to DocumentBroker
Change-Id: I684007363de6e25d78f9f1c9236fd623325da509
2017-03-10 10:47:40 +01:00
Ashod Nakashian
3cff4f69c5 nb: find existing DocumentBroker or create a new one
Change-Id: I4e15254a90bc00a77341e8dd85353aa5d68a14e0
2017-03-10 10:47:40 +01:00