class KramdownRFC::KDRFC
def process_xml_remotely(input, output, *flags)
def process_xml_remotely(input, output, *flags) warn "* converting remotely from xml #{input} to txt #{output}" if @options.verbose format = flags[0] || "--text" # warn [:V3, @options.v3].inspect maf = MODE_AS_FORMAT[@options.v3][format] unless maf raise ArgumentError.new("*** don't know how to convert remotely from xml #{input} to txt #{output}") end url = URI(XML2RFC_WEBSERVICE) req = Net::HTTP::Post.new(url) form = [["modeAsFormat", maf], ["type", "binary"], ["input", File.open(input), {filename: "input.xml", content_type: "text/plain"}]] diag = ["url/form: ", url, form].inspect req.set_form(form, 'multipart/form-data') res = Net::HTTP::start(url.hostname, url.port, :use_ssl => url.scheme == 'https' ) {|http| http.request(req) } case res when Net::HTTPOK case res.content_type when 'application/octet-stream' if res.body == '' raise IOError.new("*** HTTP response is empty with status #{res.code}, not written") end File.open(output, "w") do |fo| fo.print(res.body) end warn "* #{output} written" if @options.verbose else warning = "*** HTTP response has unexpected content_type #{res.content_type} with status #{res.code}, #{diag}" warning << "\n" warning << res.body raise IOError.new(warning) end else raise IOError.new("*** HTTP response: #{res.code}, #{diag}") end end