Special characters in cURL – especially with Solr

cURL is an excellent utility to check processing / download times of your web application. It just downloads the content from http url but gives useful insights as well. There are Linux and Windows versions of the tool.

Now, handling special characters is tricky as the command will fail. For example, below command fails as ‘[‘ character is not recognized by the tool.


curl "<a href="http://durahc109d1-stg.corp.netapp.com:8983/solr/R2B3_SYSTEM.SYSTEM/select/?q=(customer_id:%5b">http://abc.my.com:8983/solr/KeySpace.Table/select/?q=(customer_id:</a>12345 AND update_date:[2013-12-01 TO 2013-12-10])&rows=100" > out.txt

A good way to handle it is split the URL into 2 parts: first comprising of the server name and application context.  Second part with all parameters.


curl -d rows=100 --data-encodeurl <a href="http://durahc109d1-stg.corp.netapp.com:8983/solr/R2B3_SYSTEM.SYSTEM/select/?q=(customer_id:%5b">q='(customer_id:</a>12345 AND update_date:[2013-12-01 TO 2013-12-10])' <a href="http://durahc109d1-stg.corp.netapp.com:8983/solr/R2B3_SYSTEM.SYSTEM/select/?q=(customer_id:%5b">http://abc.my.com:8983/solr/KeySpace.Table/select/</a> > out.txt

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s