Note that there are some explanatory texts on larger screens.

plurals
  1. POSame request sent twice has two different responses
    primarykey
    data
    text
    <p>Please consider this test:</p> <pre class="lang-rb prettyprint-override"><code>def test_ok_on_second_request bad_response = @request.get "/bad-response" assert_equal 404, bad_response.status good_response = @request.get "/test-title" assert_equal 200, good_response.status assert_equal "text/html", good_response.content_type end </code></pre> <p>I have assured that <code>/test-title</code> is a valid path. The assertion that's supposed to return <code>200</code> is in fact returning <code>404</code>. <em>How is Rack behaving in order to return two different results for the same request?</em></p> <p>This is the code for the Server class inside the project:</p> <pre class="lang-rb prettyprint-override"><code>module Blogrite class Server attr_accessor :status, :mimetype, :body, :provider def initialize *args, &amp;block @status, @mimetype = 200, "text/html" provider = args[0][:with].nil? ? :filesystem : args[0][:with] @provider = Blogrite.const_get(provider.capitalize).new # p "Server is running with #{@provider.class}." end def call env begin article = go env['PATH_INFO'].delete("/") rescue Blogrite::Article::NoBodyError @status = 404 end @status = 404 if !article @status = 403 if env["REQUEST_METHOD"] == 'POST' @mimetype = "text/css" if env["PATH_INFO"].include?("css") @body = if article then article.render elsif env.respond_to?(:to_yaml) then "&lt;pre&gt;#{env.to_yaml}&lt;/pre&gt;" else "oops" end [@status,{ "Content-Type" =&gt; @mimetype},[@body]] end def go path f = @provider.fetch path Article.parse f unless f.nil? end end end </code></pre> <p>The whole workflow is too big for me to paste it in but you can check the project out on <a href="http://github.com/josemota/blogrite" rel="nofollow">Github</a>. I appreciate your help, thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload