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

Implement XEP-0363: HTTP File Upload: Request IQs #188

Merged
merged 1 commit into from May 4, 2019

Conversation

lnjX
Copy link
Member

@lnjX lnjX commented Jan 19, 2019

This implements the IQs for requesting and receiving upload slots as
defined by XEP-0363: HTTP File Upload [v0.9.0].

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@8cb3bb4). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #188   +/-   ##
=========================================
  Coverage          ?   66.26%           
=========================================
  Files             ?      151           
  Lines             ?    15015           
  Branches          ?        0           
=========================================
  Hits              ?     9949           
  Misses            ?     5066           
  Partials          ?        0
Impacted Files Coverage Δ
tests/qxmpphttpuploadiq/tst_qxmpphttpuploadiq.cpp 100% <100%> (ø)
src/base/QXmppHttpUploadIq.cpp 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cb3bb4...fbe8411. Read the comment docs.

@lnjX
Copy link
Member Author

lnjX commented Jan 20, 2019

added tests for ::isHttpUploadRequest() / ::isHttpUploadSlot()

doc/xep.doc Outdated
@@ -46,5 +46,6 @@ Ongoing:
- XEP-0009: Jabber-RPC (API is not finalized yet)
- XEP-0060: Publish-Subscribe (Only basic IQ implemented)
- XEP-0077: In-Band Registration (Only basic IQ implemented)
- XEP-0363: HTTP File Upload [v0.9.0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the version refer to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the XEP's version, so we can easily check if an implementation is outdated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added the version number in the header files, maybe that's a bit too much?

@lnjX lnjX force-pushed the feature/http-file-upload branch 2 times, most recently from 4403e56 to e2b59a9 Compare January 21, 2019 15:08
@lnjX
Copy link
Member Author

lnjX commented Jan 21, 2019

Now with a d-pointer.

for (QString &name : putHeaders.keys()) {
if (name == "Authorization" || name == "Cookie" || name == "Expires") {
// newlines must be removed
QString value = putHeaders[name];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced "removing" newlines is the best option. Also I expect \r isn't accepted either?

Wouldn't failing loudly be more appropriate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XEP says we must remove the newlines:

The requesting entity MUST strip any newline characters from the header name and value [...].

Would \r work on its own (without \n before)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but maybe Qt is already doing this anyway, so we might don't need to remove newlines on our own.


/// Returns the file's size in bytes.

qint64 QXmppHttpUploadRequestIq::size() const
Copy link
Contributor

@jlaine jlaine Jan 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for pointing out these things one by one.. but why fileName() vs size() ? I would expect either name() and size() or fileName() and fileSize().

QXmppTransferFileInfo use name() and size()

Ah.. actually forget this I guess it comes from the XML attribute names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah right, I took the XML attr. names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that ok or should I better use consistent names?

@jlaine
Copy link
Contributor

jlaine commented May 4, 2019

Could you rebase this please? Also, will there be a manager to handle these IQs?

This implements the IQs for requesting and receiving upload slots as
defined by XEP-0363: HTTP File Upload in version 0.9.0.
@lnjX lnjX force-pushed the feature/http-file-upload branch from 510320f to fbe8411 Compare May 4, 2019 19:52
@lnjX
Copy link
Member Author

lnjX commented May 4, 2019

Done.

Yes there will be a manager or even two: One for requesting/receiving the slots from the server and one for actually uploading a file from disk.
I just didn't want to add too much to one pull request, so reviewing is at least a bit easier.

@tehnick tehnick merged commit 9c8fea8 into qxmpp-project:master May 4, 2019
@tehnick
Copy link
Member

tehnick commented May 4, 2019

Thank you!

I just didn't want to add too much to one pull request, so reviewing is at least a bit easier.

And this really helps.

@lnjX lnjX deleted the feature/http-file-upload branch May 4, 2019 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants