Request class: Add methods to send data in chunks #13

Open
opened 11 months ago by ncc1988 · 8 comments
Owner

The Request class in the network-refactorisation1 branch doesn't have methods to send request data in chunks.

Methods to do this shall be added, working in "reverse" compared to the methods that allow reading response data in chunks.

Implementation can start as soon as #9 is finished.

The Request class in the network-refactorisation1 branch doesn't have methods to send request data in chunks. Methods to do this shall be added, working in "reverse" compared to the methods that allow reading response data in chunks. Implementation can start as soon as #9 is finished.
ncc1988 added this to the Version 0.0.1 - "Uyghur lives matter!" milestone 11 months ago
ncc1988 self-assigned this 11 months ago
ncc1988 changed title from Request class: Add request buffer to Request class: Add request buffer and methods for it 11 months ago
ncc1988 changed title from Request class: Add request buffer and methods for it to Request class: Add methods to send data in chunks 11 months ago
Poster
Owner

This is already part of #9:

Implement Request::send: Pass the (raw) data to the network handler.

This is already part of #9: > Implement Request::send: Pass the (raw) data to the network handler.
ncc1988 added the
TODO
label 11 months ago
ncc1988 added the
enhancement
wiki-doc-TODO
labels 5 months ago
Poster
Owner

This is already part of #9

No it isn't. The send method can only send a header, but no body. HTTP GET works, but HTTP POST or PUT will not work with the current code.

TODO:

  • Add a DataSource interface that defines methods for a data source that can deliver data to a Request object.
  • Add a DummyDataSource implementation of the RequestDataSource that can be used to send raw data over the network when used with the base Request class or the request class of another protocol that allows raw data.
  • Add a HTTPFormDataSource implementation that can be configured to output provided data in several formats used by HTTP forms (multipart/form-data, application/x-www-form-urlencoded, ...). The HTTPFormDataSource class shall allow selecting the format to be used.
  • Add the method Request::setDataSource that accepts a DataSource instance.
  • Add the method Request::sendData which reads a chunk of data from the DataSource instance.
  • Add a new variant of NetworkHandler::request that does not have the data parameter and instead uses Request::sendData to get the data to be sent.
  • Add a new parameter to NetworkHandler::request that allows passing a DataSource instance to it.
  • Rename the data parameter in NetworkHandler::request to request_header.
  • Extend the test for the Request class.
  • ... and the HTTPRequest class.
  • ... and the tests for the NetworkHander classes (in regard to the new request method)
  • Write a test for the DummyDataSource
  • ... and the HTTPFormDataSource class.
> This is already part of #9 No it isn't. The send method can only send a header, but no body. HTTP GET works, but HTTP POST or PUT will not work with the current code. TODO: - [x] Add a DataSource interface that defines methods for a data source that can deliver data to a Request object. - [x] Add a DummyDataSource implementation of the RequestDataSource that can be used to send raw data over the network when used with the base Request class or the request class of another protocol that allows raw data. - [ ] Add a HTTPFormDataSource implementation that can be configured to output provided data in several formats used by HTTP forms (multipart/form-data, application/x-www-form-urlencoded, ...). The HTTPFormDataSource class shall allow selecting the format to be used. - [x] Add the method Request::setDataSource that accepts a DataSource instance. - ~~[ ] Add the method Request::sendData which reads a chunk of data from the DataSource instance.~~ - ~~[ ] Add a new variant of NetworkHandler::request that does not have the data parameter and instead uses Request::sendData to get the data to be sent.~~ - [x] Add a new parameter to NetworkHandler::request that allows passing a DataSource instance to it. - [x] Rename the data parameter in NetworkHandler::request to request_header. - [ ] Extend the test for the Request class. - [ ] ... and the HTTPRequest class. - [ ] ... and the tests for the NetworkHander classes (in regard to the new request method) - [x] Write a test for the DummyDataSource - [ ] ... and the HTTPFormDataSource class.
ncc1988 added
DOING
and removed
TODO
labels 4 months ago
Poster
Owner

TODO changed: RequestDataSource is now a base class for raw request data instead of just defining the interface.

~~TODO changed: RequestDataSource is now a base class for raw request data instead of just defining the interface.~~
Poster
Owner

RequestDataSource should not be a base class for raw data sources since the implementation of the data source defines where the data will come from. That can be a HTTP form, a file, a data stream (microphone, webcam or another device) or something else.

RequestDataSource should not be a base class for raw data sources since the implementation of the data source defines where the data will come from. That can be a HTTP form, a file, a data stream (microphone, webcam or another device) or something else.
Poster
Owner

Another edit: Renamed RequestDataSource to DataSource.

Another edit: Renamed RequestDataSource to DataSource.
Poster
Owner

Another edit: One more method for the request class and one more variant for NetworkHandler implementations.

Another edit: One more method for the request class and one more variant for NetworkHandler implementations.
Poster
Owner

Edit:

Variant of NetworkHandler::request that accepts a Request instance instead of data is dropped, since the Request instance is responsible for producing the data that is then sent by the NetworkHandler.

Furthermore Request::sendData is also not necessary, since the Request instance itself knows best when to send a body.

What is necessary is that NetworkHandler::request can get a DataSource instance as additional parameter. After it has opened the connection and send the initial data (data parameter), it then uses the DataSource instance to send more data. The DataSource instance is responsible for providing data in the correct format so it should not be a problem when its data is "passed through" to the NetworkHandler directly.

Edit: Variant of NetworkHandler::request that accepts a Request instance instead of data is dropped, since the Request instance is responsible for producing the data that is then sent by the NetworkHandler. Furthermore Request::sendData is also not necessary, since the Request instance itself knows best when to send a body. What is necessary is that NetworkHandler::request can get a DataSource instance as additional parameter. After it has opened the connection and send the initial data (data parameter), it then uses the DataSource instance to send more data. The DataSource instance is responsible for providing data in the correct format so it should not be a problem when its data is "passed through" to the NetworkHandler directly.
Poster
Owner

Edit: HTTPDataSource renamed to HTTPFormDataSource.

Edit: HTTPDataSource renamed to HTTPFormDataSource.
ncc1988 referenced this issue from a commit 1 month ago
ncc1988 added
wiki-doc-DOING
and removed
wiki-doc-TODO
labels 1 month ago
ncc1988 added the
test TODO
label 1 week ago
Sign in to join this conversation.
Loading…
There is no content yet.