MaxBytesReader -> request body too large

MaxBytesReader -> request body too large

When using the MaxBytesReader like so:

r.Body = http.MaxBytesReader(w, r.Body, maxSize) 

When exactly is the "http: request body too large error" thrown? I get it with e.g. ParseMultipartForm, but is there a way to directly abort the connection when using the MaxBytesReader? Or is it needed that the returned ReadCloser is read by something like ParseMultipartForm? Anf if so, how does it know that the first x MB weren't the full request? And if it is already known, why doesn't MaxBytesReader just return an error?

Maybe something could enlight me on how the MaxBytesReader works and why the execution continues until I read from it.

Submitted February 22, 2017 at 10:57PM by ArghusSquare
via reddit

Help me code this without core.match

Help me code this without core.match

The goal here is for the match logic to be as extensible as possible without actually using core.match, because core.match uses exceptions internally which badly breaks our ClojureScript browser debugging experience, we are highly reliant on "pause on caught exceptions". (Maybe we're doing it wrong; but that's a post for another day.) param-ctx is dynamic scope, btw, it's not proper dynamic scope because React.js. We would also like the match logic to be injected as data (under user control) and be able to match directly on arbitrary bits of param-ctx in complicated ways that we can't predict today.

(defn auto-control [value field anchors param-ctx] (let [isComponent (-> (:attribute param-ctx) :attribute/isComponent) valueType (-> (:attribute param-ctx) :attribute/valueType :db/ident) cardinality (-> (:attribute param-ctx) :attribute/cardinality :db/ident) props (build-props value field anchors param-ctx) widget (cond (and (= valueType :db.type/boolean) (= cardinality :db.cardinality/one)) widget/boolean (and (= valueType :db.type/keyword) (= cardinality :db.cardinality/one)) widget/keyword (and (= valueType :db.type/string) (= cardinality :db.cardinality/one)) widget/string (and (= valueType :db.type/long) (= cardinality :db.cardinality/one)) widget/long (and (= valueType :db.type/code) (= cardinality :db.cardinality/one)) widget/string (and (= valueType :db.type/instant) (= cardinality :db.cardinality/one)) widget/instant (and (= valueType :db.type/ref) (= cardinality :db.cardinality/one) isComponent) table-cell/ref-one-component (and (= valueType :db.type/ref) (= cardinality :db.cardinality/one)) widget/ref (and (= valueType :db.type/ref) (= cardinality :db.cardinality/many)) table-cell/ref-many (and (= cardinality :db.cardinality/many)) table-cell/other-many :else (constantly [:div (pr-str [value valueType cardinality isComponent])]) ;widget/default )] (widget value field anchors props param-ctx))) 

Submitted February 22, 2017 at 10:48PM by dustingetz
via reddit

Error with Babel/React

Error with Babel/React

Getting the following error when trying to run webpack:

Command: webpack -d --watch


{ "presets" : ["es2015", "react", "stage-2"], "plugins" : ["transform-flow-comments"] } 

webpack config:

var webpack = require('webpack'); var path = require('path'); var FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin'); var config = { plugins: [ new FlowBabelWebpackPlugin(), ], entry: ['./src/app'], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', }, module : { loaders : [ { test: /\.css$/, loader: 'style!css?modules', include: /flexboxgrid/, }, { test: /\.js$/, loaders: ['babel'], include: path.join(__dirname, 'src'), }, { test: /\.less$/, loader: "style-loader!css-loader!less-loader" } ] } }; module.exports = config; ERROR in ./src/app.js Module build failed: ReferenceError: [BABEL] /Users/ user/gocode/src/ Unknown option: /Users/user/gocode/src/ Check out for more information about options. A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example: Invalid: `{ presets: [{option: value}] }` Valid: `{ presets: [['presetName', {option: value}]] }` 

It's telling me I have invalid preset options, but I don't have any, and have never had any, and all of a sudden it's breaking. What do I have to update/change to get this to work?

Submitted February 22, 2017 at 10:34PM by natdm
via reddit