-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
implementation of HTTP SEARCH method #1689
Comments
It's quite easy to do. As you can see, it's possible to construct a request with any method: static HttpMethod AsHttpMethod(Method method)
=> method switch {
Method.Get => HttpMethod.Get,
Method.Post => HttpMethod.Post,
Method.Put => HttpMethod.Put,
Method.Delete => HttpMethod.Delete,
Method.Head => HttpMethod.Head,
Method.Options => HttpMethod.Options,
#if NETSTANDARD
Method.Patch => new HttpMethod("PATCH"),
#else
Method.Patch => HttpMethod.Patch,
#endif
Method.Merge => new HttpMethod("MERGE"),
Method.Copy => new HttpMethod("COPY"),
_ => throw new ArgumentOutOfRangeException()
}; Also, a change is needed to tell RestSharp that You can make a PR to add it, should not be a lot of work. |
I was wrong about the last statement, RestSharp would add content body to any request, so it's up to the server. I added the verb, but I don't know how to test it as Kestrel doesn't support this method. |
It's in 107.0.2, without anything more than adding the verb itself. |
Hi, Thx for investigation, SEARCH method will be fine if it is Implemented, but I solved it for my Solution on an other way As I like to sear Files on NextCloud, and NC is already supporting the SEARCH method in his WEBDAV implementation
Maybe it will help someone to fix the same "Problem" THX & Regards |
I will Test 107.0.2 with NextCloud ! THX |
Hi, Looks like adding only Search is not doing the Trick.. With 107.0.2 I see the Search Method, but implementing it on the similar way I did with the WebRequest above I only get BadRequest as answer.
I tryed several ways to handover the Body, but no luck. Also WebDav methods PROPFIND, MKCOL, MOVE, LOCK, UNLOCK , are not implemented, so I think currently RestSharp is not the Lib to use if you deal with WebDAV. I will go forward and use currently standard WebRequest, or I will use PowerShell 7... the Invoke-RestMethod will do it like a charm, an also the handling of XML results is even a nice thing in PowerShell... Never the less Thx for the try on short notice. Regards & Thx |
Yes, because you need to add the string, not bytes, using I suggest using https://github.com/BSiLabs/HttpTracer to inspect the request being made with RestSharp. You can check my snipper here #885 (comment) |
You also don't set the XML content type, so I guess it won't ever work. The best solution for you is to create a class that serializes to the XML you need. Then, use If you want to post XML string as a body, you need to use |
Also, in the last alpha you can use |
I honestly don't know why you decided to send bytes array to RestSharp/src/RestSharp/Request/RestRequestExtensions.cs Lines 295 to 304 in 1556eed
|
I did not send the Byte Array..
that's in because I tested a lot, I only used the plain string variable stringData
and played with
I will try AddStringBody later, have to checkout RestsSharp first, i use the NugetPackage currently. by the way https://github.com/BSiLabs/HttpTracer is cool for tests ... |
Its me again ..
did the Trick,... but ... I got this Exception in RestResponse.cs
It looks like some encoding can not be handled with the current Implementation I changed around Line 100 in RestResponse.cs this, and it looks like the SEARCH methode is working now and delivering a result
I do not know if it is like you will do it, but it works ... |
Sorry I got confused by the first line of your snippet!
I don't think it's related to the |
Also, I am wondering what's your .NET version |
Target Framework is 4.8 VS 2022 latest patched Will try to get an RAW response from Nextcloud WebDav with the Search.
Nextcloud's WebDav implementation is somehow not every time fine, and regarding issues on GitHub somehow sometimes buggy... by the way, I also added the PROPFIND method to the Enum.cs and RestClient.Async.cs Works like it should Here is the httpResponse Object dumped in the Immediate Window
also in the Immediate Window the dump of
and the
and the
the error in the Exception from my old Post looks like well known in the World if you Google it ... one solution i found was this, but did not help...
Stragen thing ... |
It is weird because I just closed another issue where people complained that StringContent sets the charset to utf-8 in the Content-Type header :) Really weird. I don't use .NET Framework, so can't say for sure what's wrong. Why don't you try with .NET 6 instead? Any reason you prefer using .NET Framework? |
I can not use a newer Framework here, its an really old Application, and currently I am ongoing to midgrade this to an completely other solution. And therefore I has to Patchwork between the 2 Solutions ... The final Solution is running on .NET 6 an consuming Files from an Nextcloud 22 Instance. And I like to spend as less as possible time in the old Application, but as usual you can see in this case the most tricky and time consuming things are those stupid things most of the time caused by some strange Implementations done by M$ ... |
I added a wrapper to get a response string from raw response bytes instead of relying on |
Hi, Proofed it works ! THX Maybe you can also add Methodes
To on of the next Previews .. Thx |
I'd say someone can add it :) It's literally one line of code for each method. |
As of RFC 5323 (https://tools.ietf.org/html/rfc5323) a HTTP SEARCH method was proposed.
Searched in the wild for some .NET libs supporting this... nothing found ...
Will be nice if it gets implemented in RestSharp
The text was updated successfully, but these errors were encountered: