0

I am using curl command to access hadoop(webhdfs) and for http response parsing i am using python.

But after firing curl command ,multiple responses are being returned.

curl -i  "http://host:50070/webhdfs/v1/user/hduser/pigtest?op=GETFILESTATUS"

HTTP/1.1 401 Authentication required
Cache-Control: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Content-Type: plain/text
Transfer-Encoding: chunked
Server: Jetty(6.1.26.hwx)

HTTP/1.1 200 OK
Cache-Control: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Expires: Thu, 14 Jan 2016 10:04:23 GMT
Date: Thu, 14 Jan 2016 10:04:23 GMT
Pragma: no-cache
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26.hwx)

{"FileStatus":{"accessTime":1452062206193,"blockSize":134217728,"childrenNum":0,"fileId":39295,"group":"hdfs","length":753,"modificationTime":1452062206392,"owner":"hduser","pathSuffix":"","permission":"644","replication":2,"storagePolicy":0,"type":"FILE"}} 

How do i parse these multiple responses in python?

Thanks

4
  • Can you show us how you get that responses input into Python ? Commented Jan 14, 2016 at 10:25
  • That's a broken response that isn't HTTP compliant. Commented Jan 14, 2016 at 10:39
  • @Saksow: Currently i a usiin above response in string to parse it. I referred this link stackoverflow.com/questions/24728088/… Commented Jan 14, 2016 at 11:15
  • 1
    Just to give more info, I am using --negotiate -u: option along with curl as i haver kerberos enabled cluster. Commented Jan 14, 2016 at 11:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.