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

Show server response as error message in put saver #6589

Merged
merged 3 commits into from
Apr 5, 2022

Conversation

simonbaird
Copy link
Contributor

@simonbaird simonbaird commented Apr 4, 2022

I'd like to use this on Tiddlyhost so users can get more informative error messages if the put save fails for whatever reason.

This would make the put saver a viable replacement for the legacy upload saver, which is what Tiddlyhost uses currently.

I'm not sure what standard WebDAV servers do, but I would guess they don't provide any response body for put requests, and hence this patch would have no impact for a standard WebDAV server.

(That said, it would be a good idea to test it to make sure there aren't any unexpected regressions for WebDAV or other put saver compatible services.)

Also includes two related small tweaks. See commit messages for details.

@simonbaird
Copy link
Contributor Author

Second commit is kind of unrelated, so let me know if you prefer it removed from this PR.

@Jermolene
Copy link
Member

Thanks @simonbaird looks OK to me, but it would indeed be helpful to test it with WebDAV backends. I think @pmario and @saqimtiaz have done some WebDAV experiments in the last year or two?

@saqimtiaz
Copy link
Member

I use WebDAV pretty heavily and can do some testing this week. I don't foresee any issues though.

@pmario
Copy link
Member

pmario commented Apr 4, 2022

I'm using WebDav for some of my wikis and IIS as backend. I'll test it and report back

@simonbaird simonbaird force-pushed the put-saver-server-messages branch 2 times, most recently from 57c6b79 to 5457d85 Compare April 4, 2022 21:37
I'd like to use this on Tiddlyhost so users can get more informative
error messages if the put save fails for whatever reason.

This would make the put saver a viable replacement for the legacy
upload saver, which is what Tiddlyhost uses currently.

I'm not sure what standard WebDAV servers do, but I would guess they
don't provide any response body for put requests, and hence this
patch would have no impact for a standard WebDAV server. (That said,
it would be a good idea to test it to make sure there aren't any
unexpected regressions for WebDAV or other put saver compatible
services.)
There's no need to extract it from the error string created inside
tw.utils.httpRequest if we can get it directly from the xhr object.
There are two related changes here:

1. Add a 'Save starting' notification for the put saver, similar to
   the upload saver. Not sure if it was intentionally omitted for
   the put saver, but it seems reasonable to have the two be
   consistent.

2. Send the 'Save starting' notifications in both upload and put
   save right before the actual request is sent. While testing I
   noticed that the save might have failed before the "Save
   starting" notification appeared which doesn't seem useful.
@simonbaird simonbaird force-pushed the put-saver-server-messages branch from 5457d85 to 348de46 Compare April 4, 2022 21:42
@simonbaird
Copy link
Contributor Author

I added another commit to add a "Save started" notification for put saving. See commit message for details.

simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 4, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 4, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 5, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
@saqimtiaz
Copy link
Member

I'm not sure what standard WebDAV servers do, but I would guess they don't provide any response body for put requests, and hence this patch would have no impact for a standard WebDAV server.

I can confirm that a response to a PUT request from a WebDAV server has no response body for a successful request. A bit trickier to recreate error conditions, but will have another look later in the week.

@Jermolene
Copy link
Member

Thanks everyone I think that we can merge this now, but obviously further testing is welcome.

@Jermolene Jermolene merged commit 39e4e69 into TiddlyWiki:master Apr 5, 2022
simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 5, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 6, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
@simonbaird
Copy link
Contributor Author

simonbaird commented Apr 6, 2022

Thanks all!

If you want to see this in action on Tiddlyhost, follow the steps here.

simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 6, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 7, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
simonbaird added a commit to tiddlyhost/tiddlyhost-com that referenced this pull request Apr 10, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
simonbaird added a commit to simonbaird/tiddlyhost-app that referenced this pull request Apr 27, 2022
TiddlyWiki's upload.js saver is old and deprecated so let's see if
we can switch to using the put saver.

Includes:
- A bogus WebDAV header to convince TiddlyWiki that the put
  saver is usable
- A new controller method and route for the "put" saves
- Clear the url from $:/UploadURL when serving a site to make
  sure TW doesn't try to use the upload saver

There's a related PR for TiddlyWiki that exposes the error messages
to the user, see TiddlyWiki/TiddlyWiki5#6589

Issue: #148
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.

4 participants