From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92824] [Ruby trunk Bug#15873] FrozenError when using OpenURI.open
Date: Fri, 24 May 2019 13:05:17 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-78198.20190524130517.d378af046f435163@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15873.20190524091503@ruby-lang.org
Issue #15873 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Closed
Probably you are using `frozen-string-literal` pragma.
Since 2.6, OpenURI clears the buffer from `Net::HTTPResponse#read_body` to reduce memory usage.
See [Feature #14320].
----------------------------------------
Bug #15873: FrozenError when using OpenURI.open
https://bugs.ruby-lang.org/issues/15873#change-78198
* Author: AlexGascon (Alex Gascon)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I just updated from Ruby 2.5.1 to 2.6.3 and I encountered a strange problem on a part that was working fine previously. It's on a Rails application, and on one of the tests I'm stubbing (using [webmock](https://github.com/bblimke/webmock)) an HTTP request that we perform to an external URL. However, when trying to access the information by using OpenURI I get a `FrozenError`.
The following block represents a minimal reproducible example of the problem that I'm experiencing
``` ruby
stub_request(:get, "https://files.lol/certificate_doc.pdf").to_return(status: 200, body: "Random information", headers: {})
file_content = open("https://files.lol/certificate_doc.pdf")
FrozenError: can't modify frozen String
from /home/alex/.rbenv/versions/2.6.3/lib/ruby/2.6.0/open-uri.rb:357:in `clear'
```
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2019-05-24 13:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15873.20190524091503@ruby-lang.org>
2019-05-24 9:15 ` [ruby-core:92819] [Ruby trunk Bug#15873] FrozenError when using OpenURI.open alexgascon.93
2019-05-24 12:10 ` [ruby-core:92822] " nobu
2019-05-24 12:58 ` [ruby-core:92823] " alexgascon.93
2019-05-24 13:05 ` nobu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-78198.20190524130517.d378af046f435163@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).