Skip to content

Instantly share code, notes, and snippets.

View odeke-em's full-sized avatar

Emmanuel T Odeke odeke-em

View GitHub Profile
@odeke-em
odeke-em / client.go
Last active May 19, 2016 23:49
Investigating Go issue #15425
package main
import (
"crypto/tls"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
@odeke-em
odeke-em / diff.md
Last active April 11, 2016 09:09
encoding/json: cache same named fields since they are already sorted by name to ensure a constant lookup for fields of the same name
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 927f47b..0afa561 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -1123,29 +1123,33 @@ func typeFields(t reflect.Type) []field {
 
        sort.Sort(byName(fields))
 
+       nameCache := map[string][]field{}
@odeke-em
odeke-em / gifURIContentValidator.go
Created February 16, 2016 19:58
Util for validating GIF resources.
package main
import (
"fmt"
"image/gif"
"net/http"
"os"
)
func decodeGIF(url string) (*gif.GIF, error) {
@odeke-em
odeke-em / README.md
Created January 19, 2016 12:11
Fetch a URL and consume its body, useful for testing bandwidth limiting

Usage

$ # go run dlMulti.go urls...
$ go run dlMulti.go https://google.ca https://blog.golang.org https://twitter.com
@odeke-em
odeke-em / actual-differences.diff
Last active December 29, 2015 12:41
h2-fileserver coverage test
# cat coverage.diff | grep '^\(-\|+\)' > actualDifferences.diff
--- h2-fileserver-coverage 2015-12-29 05:13:58.000000000 -0700
+++ master-coverage 2015-12-29 05:13:29.000000000 -0700
@@ -196,7 +196,7 @@
-net/http/h2_bundle.go:2423: state 66.7%
+net/http/h2_bundle.go:2423: state 0.0%
@@ -222,10 +222,10 @@
-net/http/h2_bundle.go:3016: processFrame 50.0%
+net/http/h2_bundle.go:3016: processFrame 45.5%
-net/http/h2_bundle.go:3095: processResetStream 62.5%
@odeke-em
odeke-em / coverage-diff.diff
Created December 29, 2015 11:06
diff between h2 file server coverage and tip c7c7c7031d7876f6821dd1be6e8e2a24e5ff97b8
```diff
--- h2-coverage.txt 2015-12-29 03:59:30.000000000 -0700
+++ master-coverage.txt 2015-12-29 04:03:45.000000000 -0700
@@ -196,7 +196,7 @@
net/http/h2_bundle.go:2415: CloseConn 0.0%
net/http/h2_bundle.go:2417: Flush 100.0%
net/http/h2_bundle.go:2419: HeaderEncoder 100.0%
-net/http/h2_bundle.go:2423: state 66.7%
+net/http/h2_bundle.go:2423: state 0.0%
net/http/h2_bundle.go:2439: setConnState 100.0%
@odeke-em
odeke-em / excludes.py
Created December 28, 2015 03:24
drive-issue-535 contrast with other langs
#!/usr/bin/env python3
import re
reComp = re.compile('^\.(?!(mydotfile1|mydotfile2))$', re.UNICODE)
def main():
tests = ['.git', '.mydotfile', '.', '.mydotfile1', '.mydotfile2', 'other']
regexs = dict(provided=reComp)
for key, regex in regexs.items():
@odeke-em
odeke-em / client.go
Created December 19, 2015 16:05
http*-default-user-agent checks while fixing bug https://github.com/golang/go/issues/13685
package main
import (
"crypto/tls"
"io/ioutil"
"log"
"net/http"
)
func main() {
var tls = require('tls');
    var fs = require('fs');

    var options = {
      // These are necessary only if using the client certificate authentication
      key: fs.readFileSync('client-key.pem'),
      cert: fs.readFileSync('client-cert.pem'),

 // This is necessary only if the server uses the self-signed certificate
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
index 4d5bcd0..356bae0 100644
--- a/src/net/http/serve_test.go
+++ b/src/net/http/serve_test.go
@@ -2786,24 +2786,32 @@ func TestContentTypeOkayOn204(t *testing.T) {
// proxy). So then two people own that Request.Body (both the server
// and the http client), and both think they can close it on failure.
// Therefore, all incoming server requests Bodies need to be thread-safe.
-func TestTransportAndServerSharedBodyRace(t *testing.T) {
+func TestTransportAndServerSharedBodyRace_h1(t *testing.T) {