# Help understanding which changes in HTTP.jl affect this (older) function in Couchzilla.jl. Trying to update the package to julia 1.0 and recent HTTP.jl

**URL:** <https://discourse.julialang.org/t/help-understanding-which-changes-in-http-jl-affect-this-older-function-in-couchzilla-jl-trying-to-update-the-package-to-julia-1-0-and-recent-http-jl/56447>\
**Category:** Web Stack\
**Created:** [March 3, 2021, 10:05pm UTC](https://discourse.julialang.org/t/help-understanding-which-changes-in-http-jl-affect-this-older-function-in-couchzilla-jl-trying-to-update-the-package-to-julia-1-0-and-recent-http-jl/56447 "2021-03-03T22:05:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Norberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jon_norberg/32/3218_2.png) [@Jon\_Norberg](https://discourse.julialang.org/u/Jon_Norberg)\
**Post date:** [March 3, 2021, 10:05pm UTC](https://discourse.julialang.org/t/help-understanding-which-changes-in-http-jl-affect-this-older-function-in-couchzilla-jl-trying-to-update-the-package-to-julia-1-0-and-recent-http-jl/56447/1 "2021-03-03T22:05:13Z")

</div>

Hi, I just wanted to check if someone more knowledgeable in HTTP.jl could help me out with fixing another package that is a bit older and not entirely updated to recent HTTP.jl?

Couchzilla.jl is a julia interface to couchDB.

I get most things to work but there’s a function in the replication.jl file that listens for changes in the database.

```julia
function changes_streaming(db::Database;
  doc_ids = [],
  conflicts = false,
  descending = false,
  include_docs = false,
  attachments = false,
  att_encoding_info = false,
  limit = 0,
  since = 0)

  query = opts(conflicts=conflicts, descending=descending, include_docs=include_docs,
    attachments=attachments, att_encoding_info=att_encoding_info, limit=limit,
    since=since, feed="continuous", timeout=0)

  body = Dict{Any, Any}()
  headers = Dict("Content-Type" => "application/json")
  method = HTTP.get
  if length(doc_ids) > 0
    query["filter"] = "_doc_ids"
    body = Dict("doc_ids" => doc_ids)
    method = HTTP.post
  end
  stream = method(endpoint(db.url, "_changes"), headers, JSON.json(body); cookies=db.client.cookies, query=query)

  function producer(chan::Channel)
    while true
      line = strip(readline(stream))
      if length(line) > 0 && line[1] == '{'
        put!(chan, JSON.parse(line))
      end
      if eof(stream)
        break
      end
    end
  end
end

```

As far as I can understand it returns a function which one can use to listen to. According to the docs this is then how to use it:

```julia
    for ch in Channel(changes_streaming(db; limit=1))
      count += 1
    end

```

I do however, get an error that reads:

```julia
nested task error: MethodError: no method matching readline(::HTTP.Messages.Response)
    Closest candidates are:
      readline() at io.jl:506
      readline(::AbstractString; keep) at io.jl:500
      readline(::IOStream; keep) at iostream.jl:444
      ...
    Stacktrace:
     [1] (::Couchzilla.var"#producer#23"{HTTP.Messages.Response})(chan::Channel{Any})
       @ Couchzilla ~/.julia/packages/Couchzilla/tKI4Y/src/replication.jl:105
     [2] (::Base.var"#519#520"{Couchzilla.var"#producer#23"{HTTP.Messages.Response}, Channel{Any}})()
       @ Base ./channels.jl:132

```

My guess something has changed in HTTP such that the old function in Couchzilla doesn’t produce an IOStream.

Does anyone see a solution on what I need to change?

the code is found here: [couchzilla.jl](https://github.com/xpqz/Couchzilla.jl/blob/master/src/replication.jl)

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [March 4, 2021, 4:37am UTC](https://discourse.julialang.org/t/help-understanding-which-changes-in-http-jl-affect-this-older-function-in-couchzilla-jl-trying-to-update-the-package-to-julia-1-0-and-recent-http-jl/56447/2 "2021-03-04T04:37:16Z")

</div>

I believe what you will need to do is:

```julia
stream = Base.BufferStream()
method(endpoint(db.url, "_changes"), headers, JSON.json(body); cookies=db.client.cookies, query=query, response_stream=stream)

```

That should tell HTTP.jl to write the body to `stream` which the function can then call `readline()` on.

---

<div class="post-metadata">

**Author:** ![Jon\_Norberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jon_norberg/32/3218_2.png) [@Jon\_Norberg](https://discourse.julialang.org/u/Jon_Norberg)\
**Post date:** [March 4, 2021, 5:27am UTC](https://discourse.julialang.org/t/help-understanding-which-changes-in-http-jl-affect-this-older-function-in-couchzilla-jl-trying-to-update-the-package-to-julia-1-0-and-recent-http-jl/56447/3 "2021-03-04T05:27:18Z")

</div>

Thats it, thank you!
