id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c13100
return err } defer ew.Close() return e.writeBodyTo(ew) }
c13101
message.NewMultipart var h message.Header h.Set("Content-Type", "multipart/mixed") me, _ := message.NewMultipart(h, []*message.Entity{e}) mr = me.MultipartReader() } l := list.New() l.PushBack(mr) return &Reader{Header{e.Header}, e, l} }
c13102
nil && !message.IsUnknownCharset(err) { return nil, err } return NewReader(e), err }
c13103
} if pmr := p.MultipartReader(); pmr != nil { // This is a multipart part, read it r.readers.PushBack(pmr) } else { // This is a non-multipart part, return a mail part mp := &Part{Body: p.Body} t, _, _ := p.Header.ContentType() disp, _, _ := p.Header.ContentDisposition() if disp == "inline" |...
c13104
err != nil { return err } r.readers.Remove(e) } return nil }
c13105
if enc, ok := charsets[charset]; ok { return enc.NewDecoder().Reader(input), nil } return nil, fmt.Errorf("unhandled charset %q", charset) }
c13106
} if CharsetReader != nil { return CharsetReader(charset, input) } return input, fmt.Errorf("message: unhandled charset %q", charset) }
c13107
:= wordDecoder.DecodeHeader(s) if err != nil { return s, err } return dec, nil }
c13108
} header.Del("Content-Transfer-Encoding") } else { wc, err := encodingWriter(header.Get("Content-Transfer-Encoding"), ww.w) if err != nil { return nil, err } ww.w = wc ww.c = wc } switch strings.ToLower(mediaParams["charset"]) { case "", "us-ascii", "utf-8": // This is OK default: // Anythi...
c13109
if err != nil { return nil, err } if err := textproto.WriteHeader(w, header.Header); err != nil { return nil, err } return ww, nil }
c13110
cw, err := createWriter(ww, &header) if err != nil { return nil, err } pw, err := w.mw.CreatePart(headerToMap(header.Header)) if err != nil { return nil, err } ww.Writer = pw return cw, nil }
c13111
h.l = append(h.l, newHeaderField(k, v, nil)) f := &h.l[len(h.l)-1] h.m[k] = append(h.m[k], f) }
c13112
0 { return "" } return fields[len(fields)-1].v }
c13113
string) { h.Del(k) h.Add(k, v) }
c13114
h.m[textproto.CanonicalMIMEHeaderKey(k)] return ok }
c13115
textproto.CanonicalMIMEHeaderKey(k), -1} }
c13116
i++ } n := len(s) for n > i && isSpace(s[n-1]) { n-- } return s[i:n] }
c13117
} if !isSpace(c) { r.UnreadByte() break } n++ } return n }
c13118
} writeContinued(&b, v[:i]) v = v[i+1:] } return b.String() }
c13119
foldAt = foldAtEOL // if there are QP characters in the string if len(foldAtQP) > 0 { // Get the start index of the last QP character foldAtQPLastIndex := foldAtQP[len(foldAtQP)-1][0] if foldAtQPLastIndex > foldAt { // Fold at the latest QP character if there are no whitespaces after it and b...
c13120
} if _, err := w.Write(f.b); err != nil { return err } } _, err := w.Write([]byte{'\r', '\n'}) return err }
c13121
"multipart/mixed") mw, err := message.CreateWriter(w, header.Header) if err != nil { return nil, err } return &Writer{mw}, nil }
c13122
"multipart/alternative") mw, err := w.mw.CreatePart(h) if err != nil { return nil, err } return &InlineWriter{mw}, nil }
c13123
error) { initInlineHeader(&h) return w.mw.CreatePart(h.Header) }
c13124
error) { initAttachmentHeader(&h) return w.mw.CreatePart(h.Header) }
c13125
error) { initInlineHeader(&h) return w.mw.CreatePart(h.Header) }
c13126
for i := 0; i < n; i++ { kv := &args[i] if kv.Key == key { return kv } } return nil }
c13127
nil { return def } return v.StringDefault(def) }
c13128
:= gob.NewEncoder(w) err := enc.Encode(r) if err != nil { return nil } return w.Bytes() }
c13129
s.config.Expires) sess.isNew = s.provider.db.Len(sid) == 0 s.updateCookieFasthttp(ctx, sid, s.config.Expires) return sess } sess := s.provider.Read(cookieValue, s.config.Expires) return sess }
c13130
s.UpdateExpirationFasthttp(ctx, s.config.Expires) }
c13131
Default.UpdateExpiration(w, r, expires) }
c13132
s.destroy(cookieValue) RemoveCookieFasthttp(ctx, s.config) }
c13133
return strconv.Atoi(vstring) } return -1, fmt.Errorf(errFindParse, "int", key) }
c13134
} if vint, ok := v.(int); ok { return float32(vint), nil } if vstring, sok := v.(string); sok { vfloat64, err := strconv.ParseFloat(vstring, 32) if err != nil { return -1, err } return float32(vfloat64), nil } return -1, fmt.Errorf(errFindParse, "float32", key) }
c13135
{ bcookie := ctx.Request.Header.Cookie(name) if bcookie != nil { value = string(bcookie) } return }
c13136
ctx.Response.Header.SetCookie(cookie) }
c13137
{ expirationName := getExpirationBucketName([]byte(sid)) root := db.getBucket(tx) b := root.Bucket(expirationName) if b == nil { // golog.Debugf("tried to reset the expiration value for '%s' while its configured lifetime is unlimited or the session is already expired and not found now", sid) return sessi...
c13138
t.Style.htmlRules.title = outputsEnabled.titleStyle } t.outputMode = defaultOutputMode return t }
c13139
t.elements = append(t.elements, row) return row }
c13140
append(t.headers, headers...) }
c13141
} if column >= len(row.cells) { continue } row.cells[column-1].alignment = &align } }
c13142
titleStyle) { t.Style.htmlRules.title = want }
c13143
CreateCell(tt.title, &CellStyle{Alignment: AlignCenter, ColSpan: 999}) ne := []Element{ &StraightSeparator{where: LINE_TOP}, CreateRow([]interface{}{tt.titleCell}), } tt.elements = append(ne, tt.elements...) } // Create a new table from the // generate the runtime style. Must include all cells being pr...
c13144
LINE_SUBTOP: return style.BorderLeft + strings.Repeat(style.BorderX, width-1) + style.BorderRight case LINE_BOTTOM: return style.BorderBottomLeft + strings.Repeat(style.BorderX, width-1) + style.BorderBottomRight } panic("not reached") }
c13145
!= "" { nColumns, err = strconv.Atoi(columns) if err != nil || nColumns < 0 { return nil } } return &Size{ Lines: nLines, Columns: nColumns, } }
c13146
style.BorderTop) + style.BorderRight case LINE_BOTTOM: return style.BorderBottomLeft + strings.Join(parts, style.BorderBottom) + style.BorderBottomRight case LINE_INNER: return style.BorderLeft + strings.Join(parts, style.BorderI) + style.BorderRight } panic("not reached") }
c13147
[]*Cell{}} for _, item := range items { row.AddCell(item) } return row }
c13148
} else { r.cells = append(r.cells, createCell(len(r.cells), item, nil)) } }
c13149
// WAG as to max capacity, plus a bit buf := bytes.NewBuffer(make([]byte, 0, 8192)) buf.WriteString("<tr>") for i := range elems { fmt.Fprintf(buf, "<%s%s>%s</%s>", tag, attrs[i], elems[i], tag) } buf.WriteString("</tr>\n") return buf.String() }
c13150
rowsText = append(rowsText, "<tbody>\n") // loop over the elements and render them for i := range t.elements { if row, ok := t.elements[i].(*Row); ok { rowsText = append(rowsText, row.HTML("td", style)) } else { rowsText = append(rowsText, fmt.Sprintf("<!-- unable to render line %d, unhandled type -->\n", ...
c13151
float64: return strconv.FormatFloat(vv, 'f', 2, 64) case fmt.Stringer: return vv.String() } return fmt.Sprintf("%v", v) }
c13152
s.BorderBottom = "┴" s.BorderLeft = "├" s.BorderRight = "┤" s.BorderTopLeft = "╭" s.BorderTopRight = "╮" s.BorderBottomLeft = "╰" s.BorderBottomRight = "╯" }
c13153
"" { s.BorderRight = s.BorderI } if s.BorderTopLeft == "" { s.BorderTopLeft = s.BorderI } if s.BorderTopRight == "" { s.BorderTopRight = s.BorderI } if s.BorderBottomLeft == "" { s.BorderBottomLeft = s.BorderI } if s.BorderBottomRight == "" { s.BorderBottomRight = s.BorderI } }
c13154
func(old string) string { return strings.Replace(old, bad, replacement, -1) } }
c13155
{ return nil, error(e) } return &Size{ Lines: int(info.size.y), Columns: int(info.size.x), }, nil }
c13156
// create new buffer b = bytes.NewBuffer([]byte{}) } return }
c13157
} r.prepareOptions() r.compileTemplates() return &r }
c13158
*template.Template { return r.templates.Lookup(t) }
c13159
:= w.(http.ResponseWriter); err != nil && !r.opt.DisableHTTPErrorRendering && ok { http.Error(hw, err.Error(), http.StatusInternalServerError) } return err }
c13160
status, } d := Data{ Head: head, } return r.Render(w, d, v) }
c13161
} head := Head{ ContentType: r.opt.HTMLContentType + r.compiledCharset, Status: status, } h := HTML{ Head: head, Name: name, Templates: r.templates, } return r.Render(w, h, binding) }
c13162
r.opt.IndentJSON, Prefix: r.opt.PrefixJSON, UnEscapeHTML: r.opt.UnEscapeHTML, StreamingJSON: r.opt.StreamingJSON, } return r.Render(w, j, v) }
c13163
Head: head, Indent: r.opt.IndentJSON, Callback: callback, } return r.Render(w, j, v) }
c13164
Head: head, Indent: r.opt.IndentXML, Prefix: r.opt.PrefixXML, } return r.Render(w, x, v) }
c13165
h.ContentType) w.WriteHeader(h.Status) }
c13166
{ c := hw.Header().Get(ContentType) if c != "" { d.Head.ContentType = c } d.Head.Write(hw) } w.Write(v.([]byte)) return nil }
c13167
ok := w.(http.ResponseWriter); ok { h.Head.Write(hw) } out.WriteTo(w) // Return the buffer to the pool. bufPool.Put(out) return nil }
c13168
bytes.Replace(result, []byte("\\u0026"), []byte("&"), -1) } // JSON marshaled fine, write out the result. if hw, ok := w.(http.ResponseWriter); ok { j.Head.Write(hw) } if len(j.Prefix) > 0 { w.Write(j.Prefix) } w.Write(result) return nil }
c13169
{ return err } // JSON marshaled fine, write out the result. if hw, ok := w.(http.ResponseWriter); ok { j.Head.Write(hw) } w.Write([]byte(j.Callback + "(")) w.Write(result) w.Write([]byte(");")) // If indenting, append a new line. if j.Indent { w.Write([]byte("\n")) } return nil }
c13170
c := hw.Header().Get(ContentType) if c != "" { t.Head.ContentType = c } t.Head.Write(hw) } w.Write([]byte(v.(string))) return nil }
c13171
hw, ok := w.(http.ResponseWriter); ok { x.Head.Write(hw) } if len(x.Prefix) > 0 { w.Write(x.Prefix) } w.Write(result) return nil }
c13172
return d.runAfter("response", ctx) }, } // Reference to initial context ctx := d.req.Context // Execute tasks in order, stopping in case of error or explicit stop. for _, task := range pipeline { var stop bool if ctx, stop = task(ctx); stop { break } } return ctx }
c13173
s.stack = append(s.stack, plugin) s.mtx.Unlock() return s }
c13174
{ s.mtx.Lock() s.stack = append(s.stack, plugin.NewPhasePlugin(phase, fn)) s.mtx.Unlock() return s }
c13175
s.stack = s.stack[:0] s.mtx.Unlock() }
c13176
defer s.mtx.RUnlock() return s.stack }
c13177
= append([]plugin.Plugin(nil), s.stack...) s.mtx.Unlock() return mw }
c13178
u, err := url.Parse(normalize(uri)) if err != nil { h.Error(ctx, err) return } ctx.Request.URL = u h.Next(ctx) }) }
c13179
ctx.Request.URL.Path = normalizePath(path) h.Next(ctx) }) }
c13180
*c.Context, h c.Handler) { ctx.Request.URL.Path = replace(ctx.Request.URL.Path, key, value) h.Next(ctx) }) }
c13181
ctx.Request.ContentLength = int64(bytes.NewBufferString(data).Len()) h.Next(ctx) }) }
c13182
= getMethod(ctx) ctx.Request.Body = ioutil.NopCloser(buf) ctx.Request.ContentLength = int64(buf.Len()) ctx.Request.Header.Set("Content-Type", "application/json") h.Next(ctx) }) }
c13183
req.ContentLength = int64(v.Len()) case *strings.Reader: req.ContentLength = int64(v.Len()) } } req.Body = rc ctx.Request.Method = getMethod(ctx) h.Next(ctx) }) }
c13184
_, mm := range muxes { mx.AddMatcher(mm.Matchers...) } return mx }
c13185
{ if mm.Match(ctx) { return true } } return false }) }
c13186
New() mx.AddMatcher(matchers...) return mx }
c13187
"request" { return false } matched, _ := regexp.MatchString(pattern, ctx.Request.URL.Path) return matched }) }
c13188
kind = value } return strings.Contains(ctx.Response.Header.Get("Content-Type"), kind) }) }
c13189
codes { if ctx.Response.StatusCode == code { return true } } return false }) }
c13190
return ctx.GetString("$phase") == "response" && ctx.Response.StatusCode >= start && ctx.Response.StatusCode <= end }) }
c13191
(ctx.GetString("$phase") == "response" && ctx.Response.StatusCode >= 500) }) }
c13192
ctx.GetString("$phase") == "response" && ctx.Response.StatusCode >= 500 }) }
c13193
:= m.Handler() m.DefaultHandler = handler return m }
c13194
:= range m.Matchers { if !matcher(ctx) { return false } } return true }
c13195
= append(m.Matchers, matchers...) return m }
c13196
h.Error(ctx, ctx.Error) return } if ctx.Stopped { h.Stop(ctx) return } h.Next(ctx) } }
c13197
*Mux { m.Middleware.Use(p) return m }
c13198
*Mux { m.Middleware.UseHandler(phase, fn) return m }
c13199
{ return All(Timeouts{TLS: timeout}) }