mattg / jekyll-download-tag

This Jekyll plugin creates a 'download' Liquid Template tag. I use it to download external resources for inlining.
7 stars 0 forks source link

Liquid Exception: 400 Bad Request #1

Open Phlow opened 8 years ago

Phlow commented 8 years ago

Hey @mattg, when I saw your plugin I thought, that's the plugin I waited for, because I want to use data from one jekyll website on another. I followed your steps, pasted the code

{% capture styles %}
  {% download https://fonts.googleapis.com/css?family=Arvo %}
  {% download https://fonts.googleapis.com/css?family=Open+Sans %}
{% endcapture %}

into a test-site and the terminal/jekyll spits out Liquid Exception: 400 Bad Request

Do you have an idea, what's wrong?

mattg commented 8 years ago

Not sure. Just to be sure that Google hasn't changed something, I rebuilt my site and it works.

To make things simpler to debug, let's reduce the number of downloads and use a URL I control. Try this and let me know what happens:

{% capture styles %}
  {% download http://www.matthewgifford.com/blog/wp-content/themes/mg2013/style.css %}
{% endcapture %}
Phlow commented 8 years ago

Now I get this

Liquid Exception: bad URI(is not URI?): http://www.matthewgifford.com/blog/wp-content/themes/mg2013/style.css
Phlow commented 8 years ago

What version of Jekyll do you use?

Phlow commented 8 years ago

Or does it maybe depend on the ruby version?

I use

$ ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]

Unfortunately I am no ruby programmer :(

mattg commented 8 years ago

I'm using Jekyll 3.2.1 and Ruby 2.0.0p353.

Phlow commented 8 years ago

hm… I use the actual version jekyll 3.3.1

I don't want to steal your time. Maybe if you get an idea in the future, you tell me.

mattg commented 8 years ago

I feel like something other than the code is the problem. It's strange that it's telling you that http://www.matthewgifford.com/blog/wp-content/themes/mg2013/style.css is not a URI, when it quite clearly is. I'm going to keep thinking about this for a while.

Phlow commented 8 years ago

Meanwhile I update Ruby to the stable version 2.3.2

and I found this, but I don't know if that is helpful: http://stackoverflow.com/questions/15700784/how-to-fix-bad-uri-is-not-uri

DirtyF commented 7 years ago

Stumble on the same error as I was checking your plugin before adding it to new Jekyll plugins directory 😲

  Liquid Exception: 400 Bad Request in /_layouts/default.html
bundler: failed to load command: jekyll (/Users/frank/.rbenv/versions/2.4.1/bin/jekyll)
OpenURI::HTTPError: 400 Bad Request
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:363:in `open_http'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:741:in `buffer_open'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:212:in `block in open_loop'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:210:in `catch'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:210:in `open_loop'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:151:in `open_uri'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:721:in `open'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/2.4.0/open-uri.rb:35:in `open'
  /Users/frank/code/jekyll/directory/_plugins/download.rb:11:in `render'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/block.rb:151:in `render_token'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/profiler/hooks.rb:5:in `block in render_token_with_profiling'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/profiler.rb:80:in `profile_token_render'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/profiler/hooks.rb:4:in `render_token_with_profiling'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/block.rb:135:in `block in render_all'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/block.rb:122:in `each'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/block.rb:122:in `render_all'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/block.rb:108:in `render'
  /Users/frank/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/liquid-3.0.6/lib/liquid/tags/capture.rb:26:in `render'
...

Made a few tests, it's as if you were passing a incorrect URL to open like:

#!/usr/bin/env ruby
require 'open-uri'

urls= 'https://fonts.googleapis.com/css?family=Arvo' 'https://fonts.googleapis.com/css?family=Open+Sans'

puts open(urls).read

Not Ruby-saavy enough to help you debug this, sorry.