java-technotes

Tuesday, September 17, 2013

Using curl as REST Client



Simple REST call
------------------

$ curl http://www.purgomalum.com/service/xml?text=HellowWorld  -L -k -x  www-myproxy-mydomain.com:80
HellowWorld


Rest call With proxy parameter
----------------------------
$ curl http://www.purgomalum.com/service/xml?text=HellowWorld  -L -k -x www-myproxy-mydomain.com:80
HellowWorld


Call REST and see the header info using -v 
--------------------------------------------

$ curl http://www.purgomalum.com/service/xml?text=HellowWorld  -L -k -x www-myproxy-mydomain.com:80   -v
* Adding handle: conn: 0x1e22f68
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1e22f68) send_pipe: 1, recv_pipe: 0
* About to connect() to proxy www-myproxy-mydomain.com:80 port 80 (#0)
*   Trying 144.20.66.148...
* Connected to www-myproxy-mydomain.com:80 (IP Address) port 80 (#0)
> GET http://www.purgomalum.com/service/xml?text=HellowWorld HTTP/1.1
> User-Agent: curl/7.30.0
> Host: www.purgomalum.com
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Tue, 17 Sep 2013 10:15:14 GMT
< Content-Type: application/xml
< Cache-Control: private
< Vary: Accept-Encoding
* Server Google Frontend is not blacklisted
< Server: Google Frontend
< Alternate-Protocol: 80:quic,80:quic
< Via: 1.1 inet-nc08 (NetCache NetApp/6.0.6)
<
HellowWorld* Connection #0 to host www-myproxy-mydomain.com left intact