<commit_before>package websocket

import (
	"net/http"

	ws "github.com/gorilla/websocket"
)

var upgrader = ws.Upgrader{
	ReadBufferSize:  2048,
	WriteBufferSize: 2048,
}

//ConnectionFactory is a wrapper interface over gorilla websocket upgrader struct
type ConnectionFactory interface {
	UpgradeConnection(writer http.ResponseWriter, req *http.Request, channels []string) (*Connection, error)
}

type gorillaFactory struct {
	u ws.Upgrader
}

//NewFactory is the connection factory constructor
func NewFactory() ConnectionFactory {
	g := gorillaFactory{ws.Upgrader{}}
	return &g
}

//UpgradeConnection upgrades HTTP connection to a websocket
func (g *gorillaFactory) UpgradeConnection(writer http.ResponseWriter, req *http.Request, channels []string) (*Connection, error) {
	var err error
	var w *ws.Conn
	if w, err = g.u.Upgrade(writer, req, nil); err != nil {
		return nil, err
	}
	return newConnection(w, req.RemoteAddr, channels), nil
}<commit_msg>refac(upgrader): temporarily disabled origin check<commit_after>package websocket

import (
	"net/http"

	ws "github.com/gorilla/websocket"
)

var upgrader = ws.Upgrader{
	ReadBufferSize:  2048,
	WriteBufferSize: 2048,
}

//ConnectionFactory is a wrapper interface over gorilla websocket upgrader struct
type ConnectionFactory interface {
	UpgradeConnection(writer http.ResponseWriter, req *http.Request, channels []string) (*Connection, error)
}

type gorillaFactory struct {
	u ws.Upgrader
}

//NewFactory is the connection factory constructor
func NewFactory() ConnectionFactory {
	g := gorillaFactory{ws.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }}}
	return &g
}

//UpgradeConnection upgrades HTTP connection to a websocket
func (g *gorillaFactory) UpgradeConnection(writer http.ResponseWriter, req *http.Request, channels []string) (*Connection, error) {
	var err error
	var w *ws.Conn
	if w, err = g.u.Upgrade(writer, req, nil); err != nil {
		return nil, err
	}
	return newConnection(w, req.RemoteAddr, channels), nil
}
{'fraction_non_alphanumeric': 0.1018981018981019, 'fraction_numerical': 0.007992007992007992, 'mean_word_length': 5.318611987381703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7500792', 'n_tokens_mistral': 645, 'n_tokens_neox': 611, 'n_words': 193}