Coder Social home page Coder Social logo

rack-headers-readme's Introduction

Headers

Headers are specifications passed along in the response that are essential for setting up the Rack environment.

HTTP and headers

In order to understand the structure, we'll use HTTP protocols for simplicity. Everything you see in your browser, for example, is transferred via HTTP. Navigating the web is essentially a large series of HTTP requests and responses, and these are transported by HTTP headers in your metadata.

Live HTTP Headers

If you're using Firefox or Chrome, you can use the Live HTTP Headers extension to see what these HTTP Headers look like. Once you enable it to capture your requests and responses, you can click on a logged request/response and see the corresponding HTTP Headers.

Rack Header

Rack uses these headers to set up the environment in accordance with the HTTP standard. The header is simply a hash that contains these header elements. For example, the following is a Rack response for a ResponseTimer Rack app:

class ResponseTimer
  def initialize(app)
    @app = app
  end

  def call(env)
    [200, {"Content-Type" => "text/html"}, "Hello World!"]
  end
end

The header in this response is {"Content-Type" => "text/html"}. This is simply saying that the content type of this response is text/html, and this will render the body Hello World! in the HTML text formatting language.

Resources

View Headers on Learn.co and start learning to code for free.

rack-headers-readme's People

Contributors

annjohn avatar cmc33 avatar deniznida avatar fislabstest avatar fs-lms-test-bot avatar irmiller22 avatar sarogers avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rack-headers-readme's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.