<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>HTTP on Random Musings</title><link>https://chengl.com/tags/http/</link><description>Recent content in HTTP on Random Musings</description><generator>Hugo</generator><language>en-us</language><copyright>Cheng Long</copyright><lastBuildDate>Sun, 30 Jul 2017 09:32:10 +0000</lastBuildDate><atom:link href="https://chengl.com/tags/http/index.xml" rel="self" type="application/rss+xml"/><item><title>Be wary of http/client.go</title><link>https://chengl.com/post/be-wary-of-go-http-client/</link><pubDate>Sat, 25 Mar 2017 09:30:00 +0000</pubDate><guid>https://chengl.com/post/be-wary-of-go-http-client/</guid><description>&lt;p&gt;Recently, I found out an interesting problem in Go. The problem can be reduced to a simple client request to a HTTP server.&lt;/p&gt;
&lt;p&gt;Suppose we have a HTTP server, which serves only one rooted path &lt;code&gt;/foo/&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;package main

import (
	&amp;quot;io&amp;quot;
	&amp;quot;log&amp;quot;
	&amp;quot;net/http&amp;quot;
	&amp;quot;net/http/httputil&amp;quot;
)

func handleFoo(w http.ResponseWriter, req *http.Request) {
	// request details
	dump, _ := httputil.DumpRequest(req, true)
	log.Println(string(dump))

	if auth := req.Header.Get(&amp;quot;Authorization&amp;quot;); auth != &amp;quot;Bearer GoodToken&amp;quot; {
		http.Error(w, &amp;quot;401 Unauthorized&amp;quot;, http.StatusUnauthorized)
		return
	}

	io.WriteString(w, &amp;quot;Hello World!&amp;quot;)
}

func main() {
	http.HandleFunc(&amp;quot;/foo/&amp;quot;, handleFoo)
	log.Fatal(http.ListenAndServe(&amp;quot;:12345&amp;quot;, nil))
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;handleFoo&lt;/code&gt; simplily verifies that correct token is sent in the &lt;code&gt;Authorization&lt;/code&gt; header. Otherwise, it returns &lt;code&gt;401 Unauthorized&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>HTTP/2</title><link>https://chengl.com/post/http2/</link><pubDate>Mon, 14 Mar 2016 08:53:00 +0000</pubDate><guid>https://chengl.com/post/http2/</guid><description>&lt;h3 id="what-is-http2-and-why"&gt;What is HTTP/2 and Why&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://tools.ietf.org/html/rfc2068"&gt;HTTP/1.1&lt;/a&gt; has been serving most part of the Web since 1997. As websites get more and more sophisticated and resource intensive, it starts to show its limitations, e.g. one outstanding request per TCP connection. So its next-generation emerged: &lt;a href="http://http2.github.io/"&gt;HTTP/2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://http2.github.io/faq/"&gt;HTTP/2 FAQ&lt;/a&gt; does a great job explaining the background and specifications. Highly recommended. Here is an executive summary, HTTP/2:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;is specifically designed to improve performance&lt;/li&gt;
&lt;li&gt;is based on &lt;a href="http://tools.ietf.org/html/draft-mbelshe-httpbis-spdy-00"&gt;SPDY&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;is binary, instead of textual&lt;/li&gt;
&lt;li&gt;is fully multiplexed, instead of ordered and blocking&lt;/li&gt;
&lt;li&gt;can therefore use one connection for parallelism&lt;/li&gt;
&lt;li&gt;uses header compression to reduce overhead&lt;/li&gt;
&lt;li&gt;allows servers to push responses proactively into client caches&lt;/li&gt;
&lt;li&gt;is backward-compatible, designed to be drop-in replacement for HTTP/1.1&lt;/li&gt;
&lt;li&gt;is &lt;a href="http://caniuse.com/#search=http%2F2"&gt;supported by most broswers over TLS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;HttpWatch &lt;a href="https://blog.httpwatch.com/2015/01/16/a-simple-performance-comparison-of-https-spdy-and-http2/"&gt;reported&lt;/a&gt; good performance improvement by using HTTP/2.&lt;/p&gt;</description></item><item><title>HTTP/2</title><link>https://chengl.com/post/http2/</link><pubDate>Mon, 14 Mar 2016 08:53:00 +0000</pubDate><guid>https://chengl.com/post/http2/</guid><description>&lt;h3 id="what-is-http2-and-why"&gt;What is HTTP/2 and Why&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://tools.ietf.org/html/rfc2068"&gt;HTTP/1.1&lt;/a&gt; has been serving most part of the Web since 1997. As websites get more and more sophisticated and resource intensive, it starts to show its limitations, e.g. one outstanding request per TCP connection. So its next-generation emerged: &lt;a href="http://http2.github.io/"&gt;HTTP/2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://http2.github.io/faq/"&gt;HTTP/2 FAQ&lt;/a&gt; does a great job explaining the background and specifications. Highly recommended. Here is an executive summary, HTTP/2:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;is specifically designed to improve performance&lt;/li&gt;
&lt;li&gt;is based on &lt;a href="http://tools.ietf.org/html/draft-mbelshe-httpbis-spdy-00"&gt;SPDY&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;is binary, instead of textual&lt;/li&gt;
&lt;li&gt;is fully multiplexed, instead of ordered and blocking&lt;/li&gt;
&lt;li&gt;can therefore use one connection for parallelism&lt;/li&gt;
&lt;li&gt;uses header compression to reduce overhead&lt;/li&gt;
&lt;li&gt;allows servers to push responses proactively into client caches&lt;/li&gt;
&lt;li&gt;is backward-compatible, designed to be drop-in replacement for HTTP/1.1&lt;/li&gt;
&lt;li&gt;is &lt;a href="http://caniuse.com/#search=http%2F2"&gt;supported by most broswers over TLS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;HttpWatch &lt;a href="https://blog.httpwatch.com/2015/01/16/a-simple-performance-comparison-of-https-spdy-and-http2/"&gt;reported&lt;/a&gt; good performance improvement by using HTTP/2.&lt;/p&gt;</description></item></channel></rss>