How do I get the properties of a webdav URL? - webdav

I have a webdav server I can connect to, how do I get the properties such as last modified time, etc. ?

You send a PROPFIND request as defined in RFC 4918.

Related

Get hash tag(#) character of URL in servlet request

I have a URL abc.com/#cancel. In my servlet I need to store #cancel for future use. I have already tried HttpServletRequest getRequestURI() and few other options. But don't see this value in request object. How do I get this value.
In my application I am using GWT which uses rpc calls and rpc request is made based on the hash tag value. eg: mydomain.com/#profile, forwards the request to profile.rpc. In my case I am intercepting this call with a filter which does some basic check and then I want to forward the request again to mydomain.com/#profile. but I am not able to find #profile in request object. Hope this explains my question and what I am looking for.
You cannot get the fragment part of a URL server side, as the browser won't send it to the server.
Eg: User click a link to http://www.example.com/foo#bar. Browser connect to www.example.com and send:
GET /foo HTTP/1.1
Host: www.example.com
Hash(#) is used to separate fragment from Url. Fragment is an optional part of the URL and is used to address a particular part of a resource.
please see below links
http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/
URL fragment (#) allowed characters
List of valid characters for the fragment identifier in an URL?
request.getRequestURI() will gives you the url eg:abc.com/#cancel.
String url1=request.getRequestURI();
url1.split("/");
Found out that fragmented URL doesn't come in request, when we do response.sedRedirect(), browser doesn't remove the fragmented part from browser URL bar. But not sure how this happens. Anyways in my case instead of posting request to another JSP and then submitting the form to different URL, I am directly doing response.sendRedirect(), which doesn't remove the fragmented part, so its working now :)

webMethods pub.client.http throws error on 401

I am using webMethods from the SAG and it seems if the service
pub.client.http
throws an exception on status code 401 "Unauthorized".
This leads me to the problem that I cannot handle the status code because nothing is written to the pipeline.
getLastError
does contain the string "Unauthorized" but not the status code.
Except that I do not want to start parsing exception messages...
Any ideas?
The output parameter header from the pub.client.http call should contain the information you’re after:
header Document Conditional. HTTP response headers.
Key Description
lines Document Fields in the response header, where key names represent
field names and values represent field values.
status String HTTP status code of the response.
statusMessage String HTTP status message of the response.
See the webMethods Integration Server Built-In Services Reference page 122 for more details.
Asked a SAG senior consultant.
This is the normal behavior.
There is no flag which you can set to enforce suppression of this exception...
You can suppress the exception and have the HTTP 401 status returned like any other HTTP response. Go to the IS Admin Extended Settings and set:
watt.net.http401.throwException=false
Note this is a server-wide setting, so it will affect all your applications/services that use pub.client:http.
According the comment from #Hugo Ferreira probably there are ACL restriction whether inside your webMethods environment, or your client URLs.
Things you should consider:
Do your webMethods server located inside closed environment wherein need to get connected to proxy to get to the outgoing request. Which is likely you can investigate by run web-browser program directly from your wM server towards the URL address (i.e using SSH to run firefox in my case and popup appeared)
The client that your request will go to, have HTTP for authentication requests
Solution
To pass this all you need to do is input the auth user/password or any other auth mechanism i.e kerberos, token, etc. inside the pub.client:http

How to send HTTP Delete request with custom headers?

I have a web server running on an EC2 node. There is an endpoint which accepts HTTP DELETE requests. It accepts the requests and proceeds with the intended functionality only if some certain headers are found in the DELETE request it send. What would be the easiest way to test this?
Check http://www.hurl.it/
Set the type the DELETE, and click Add Headers to add the headers you want.

Does a 302 Redirect requires a GET request?

I am building an API for a web service and I have been asking myself. Imagine there as an API call to create a new project, like /api/project/create.json and it redirects (with a 302 Redirect) to the newly created project, say /api/project/123.json. If the first request is sent via POST, where is specifed, that the second URI must be retrived with GET?
Is there any RFC that states, that redirects always must be followed with GET? Or is it valid client behavior to just change the URL and send the same POST request again to the new URL?
Imagine I have and old API server and a new API server and I wanted to redirect the clients POST-Request to the new API-URL. What do I have to do?
If the first request is sent via POST, where is specifed, that the second URI must be retrived with GET?
Nowhere.
Is there any RFC that states, that redirects always must be followed with GET? Or is it valid client behavior to just change the URL and send the same POST request again to the new URL?
No, actually the RFC (RFC 2616) states that changing the method name on 301 and 302 is incorrect.
See also http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-19.html#status.3xx for more information.
Imagine I have and old API server and a new API server and I wanted to redirect the clients POST-Request to the new API-URL. What do I have to do?
I would recommend using status code 307 (because there are fewer browser bugs around that one).

Generating HTTP Request

In how many ways can an HTTP request be generated?
There are endless ways how you can create and from where you can send HTTP requests to a server. Actually your server has no idea, what the origin of such a request is (if it's AJAX or "regular" request, or sent from a console application or ...)
But there are HTTP methods (HTTP verbs) that (can) tell the server about the intent of the request: http://en.wikipedia.org/wiki/HTTP_Verbs#Request_methods
Also you can set headers in a request, for example the content-type or the accepted encoding: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
Most JavaScript libraries for example set the (non-standard) HTTP header X-Requested-With, so your application can differentiate between regular and ajax requests.
You see, it's even possible to set your own, non-standard headers. There are endless possible combinations...
HttpRequest is a C# class that wraps a petition sent by a client during a Web request.
There are many ways to generate it. The most usual one happens when your browser connects to an ASP.NET website.
You can, for example, create your own custom HttpRequest to petition a specific web page from a C# console application.
Are you trying to achieve something more specific?

Resources