How to check http methods supported by the tomcat - java

In below code sample am getting the http method get is used as reQuest now want to know what are all the http methods my tomcat server support.Please help to find this.
GET / HTTP/1.0
Connection: Keep-Alive
User-Agent: Mozilla/4.6 (X11; I; Linux 2.2.6-15apmac ppc)
Host: zink.demon.co.uk:1126
Accept: image/gif, */*

There is no way to know this unless you ask the server which methods it supports.
Usually this is done with the OPTIONS HTTP method, but not all web servers support it. Also, it applies to a specific URL, not the whole server.

Related

Keep-Alive Dropwizard

I understand Jetty can be configured via the config file within Dropwizard, however I cannot find a way to enable Keep-Alive, any suggestions on how to implement this rather than a custom filter?
server:
type: simple
applicationContextPath: /
adminContextPath: /admin
connector:
type: http
port: 8080
gzip:
bufferSize: 8KiB
HTTP keep-alive support is available by default in Jetty when using HTTP/1.0
The use of HTTP/1.0 keep-alive is dependent on the HTTP Client (its chosen HTTP version support level, and the headers it sends).
Note that keep-alive is an invalid term/concept/setting/header when using HTTP/1.1 (it has no meaning on HTTP/1.1).
HTTP/1.1 is connection persistent by default, and you would need to pass a Connection: close header to request that the connection is closed after the current HTTP exchange.

Java http request for django rest framework service throws http 406 exception

I hava a django rest framework web service that works fine with httpie and firefox: when I request with httpie I have a json formatted answer and when I request with firefox an html formatted one (httpie is a http client).
Now I'm building java API to communicate with services. I'm using URL class to perform requests.
I can receive html-formatted answers from the server if I don't override the content-type property. So I looked how httpie overrides this property and did the same:
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
connection.setRequestProperty("Accept", "*\\*");
Now the communication end with Http 406 error, which means that client can't accept the answer.
If I use only the content-type property I have no error but still the html-formatted answer
Does anyone know how to solve it?
EDIT (adding requests' header):
httpie:
GET /match/39.3280114/16.241917599999965/0/5/ HTTP/1.1
Host: 127.0.0.1:8001
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: /
User-Agent: HTTPie/0.9.3
java-API
GET /match/39.3280114/16.241917599999965/0/5/ HTTP/1.1
Host: 127.0.0.1:8001
Accept-Encoding: gzip, deflate
Accept: **
User-Agent: Java-API
Solved: I was using the wrong slash for Accept property
Your Accept header is malformed. It should be:
Accept: */*
See RFC 7231 § 5.3.2.
However, */* means “any media type.” If you actually want a specific media type (JSON), you should request it:
Accept: application/json

Jetty returns 400 for requests for absolute URL in the http request

I've replaced the Tomcat by Jetty. Now I have 400 http error code for requests sent by a third party system. As I see, the difference with my tests sent by curl and a web-browser is the url in the http verb:
POST http://10.15.1.9:49302 HTTP/1.0
Host: 10.15.1.9
Content-Type: text/xml
Content-Length: 71065
User-Agent: hpost/0.1
Pragma: no-cache
Accept: */*
this request doesn't work, but post with relative URL such as POST / HTTP/1.0 works fine. Who is wrong? I cannot change the third party system, so, is it possible to make jetty accept such requests?
I've tried Jetty v6.1.26, v7.6.4 and v8.1.4 - works the same.
Ok, I think the reason is missing trailing slash after the url, the POST http://10.15.1.9:49302/ HTTP/1.0 works fine.
Does any body know if it is jetty problem or the client sends malformed url?
While the HTTP spec RFC-2616 says that the server must accept absoluteuri's for the request line, this is generally only used for proxy requests.
To Jetty, the request line POST http://10.15.1.9:49302 HTTP/1.0 is viewed as a HTTP/1.0 request, and fall into the rules of RFC-1945 for Request Line URIs that states absoluteuri's are always Proxy requests.
I've reported the issue, it is fixed now.

Webscarab refusing connections with all browsers

Hi I am using webscarab as proxy to see the conversations between my browser and server. I havent used webscarab in a while. It was ok when I used it before. But now all the connections are refused , with all browsers or ports. It is showing an exception like below.
WebScarab encountered an error trying to retrieve
GET http://www.gooogle.com:80/ HTTP/1.1
Host: www.gooogle.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Proxy-Connection: keep-alive
Cache-Control: max-age=0
The error was :
Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at org.owasp.webscarab.httpclient.URLFetcher.connect(URLFetcher.java:368)
at org.owasp.webscarab.httpclient.URLFetcher.fetchResponse(URLFetcher.java:229)
at org.owasp.webscarab.plugin.proxy.CookieTracker$Plugin.fetchResponse(CookieTracker.java:130)
at org.owasp.webscarab.plugin.proxy.BrowserCache$Plugin.fetchResponse(BrowserCache.java:101)
at org.owasp.webscarab.plugin.proxy.RevealHidden$Plugin.fetchResponse(RevealHidden.java:100)
at org.owasp.webscarab.plugin.proxy.BeanShell$Plugin.fetchResponse(BeanShell.java:229)
at org.owasp.webscarab.plugin.proxy.ManualEdit$Plugin.fetchResponse(ManualEdit.java:243)
at org.owasp.webscarab.plugin.proxy.ConnectionHandler.run(ConnectionHandler.java:233)
at java.lang.Thread.run(Thread.java:636)
This is the error I get from firefox now. I tried changing the listener ports, and browsers. But no use. Still getting same exception. Can someone please help.
The most likely problem is that there is a proxy configured in WebScarab itself, that WebScarab cannot reach. To check this, go to Tools -> Proxies, and make sure that there is no proxy configured (unless you need an upstream proxy to reach the sites normally, in which case make sure that that is properly configured.)
Connection between javafx2.2 webengine and webscarab fails
it worked for me.

Understanding SOAPAction in http header (Java somewhat involved)

I noticed my home router has some configuration field "TR-069 CLIENT CONFIGURATION" and some obscure address that I noticed gets resolved quite often each day. (Yes obviously to config the router remotely.. or something) But I want to see what is being sent. So wrote a very simple "web server" in Java to read in HTTP requests (the field in the router was with a normal http:// address) and print them out. (i set that field to point to my computer where the little server is running)
And im getting these:
Host: 192.168.1.2
User-Agent: Allegro-Software-WebClient/4.07
Accept: */*
Content-Type: text/xml; charset=utf-8
Content-Length: 2767
SOAPAction:
Was kind of hoping SOAPAction: wouldnt be empty but what does this mean, is it some deprecated feature of the router that just happens to keep going? (its a d-link ADSL Router)
There would be multiple soap envelopes in HTTP Request.
TR-069 spec says
When there is more than one envelope
in a single HTTP Request, the
SOAPAction header in the HTTP Request
MUST have no value (with no quotes),
indicating that this header provides
no information as to the intent of the
message. That is, it should appear as
follows:
SOAPAction:

Categories

Resources