{"action":"closed","issue":{"url":"https://api.github.com/repos/bagder/curl/issues/467","labels_url":"https://api.github.com/repos/bagder/curl/issues/467/labels{/name}","comments_url":"https://api.github.com/repos/bagder/curl/issues/467/comments","events_url":"https://api.github.com/repos/bagder/curl/issues/467/events","html_url":"https://github.com/bagder/curl/issues/467","id":109334389,"number":467,"title":"Doesn't reject invalid HTTP response","user":{"login":"ianpark","id":4631393,"avatar_url":"https://avatars.githubusercontent.com/u/4631393?v=3","gravatar_id":"","url":"https://api.github.com/users/ianpark","html_url":"https://github.com/ianpark","followers_url":"https://api.github.com/users/ianpark/followers","following_url":"https://api.github.com/users/ianpark/following{/other_user}","gists_url":"https://api.github.com/users/ianpark/gists{/gist_id}","starred_url":"https://api.github.com/users/ianpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianpark/subscriptions","organizations_url":"https://api.github.com/users/ianpark/orgs","repos_url":"https://api.github.com/users/ianpark/repos","events_url":"https://api.github.com/users/ianpark/events{/privacy}","received_events_url":"https://api.github.com/users/ianpark/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bagder/curl/labels/HTTP","name":"HTTP","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-01T16:19:19Z","updated_at":"2015-10-04T10:12:38Z","closed_at":"2015-10-04T10:12:38Z","body":"Hi,\r\n\r\nI am using libCur 7.42.1.1. While running Codenomicon with our http interface which is built with libCurl, I found something working ambiguous or wrong.\r\n\r\nIf peer sends back a dummy data like \"aaaaaaaaaaaaaaa\" without HTTP response result code or headers, the write function is called with the raw data. As far as I know the write function will be only called with HTTP response body so my code just stores on the buffer whatever given.\r\n\r\nAfter then, The task is completed with CURLE_OK. How come it is OK when the response is not HTTP response. And the when I get the HTTP response code using get_easy_info, it returns 0.\r\n\r\nSo I put workaround fix:\r\n1. check response code in the write function\r\n2. if response code is 0, regard it as there were no HTTP header so handle it as a raw data or return 0 to reject the download.\r\n\r\nWhat's more proper way to handle this case? How to reject if the response is not following HTTP standard. Why doesn't curl handle this case by checking the protocol and not calling write function at all?\r\n\r\nI am not allowed to upload any pcap files so I attach a snapshot.\r\n\r\n![aaa](https://cloud.githubusercontent.com/assets/4631393/10226616/7b3cf5ac-6860-11e5-9027-5ce58a59a28c.PNG)\r\n"}}