Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
7c7a525d
Commit
7c7a525d
authored
Oct 20, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add io.ReadWriteClose and use it in http
R=r DELTA=15 (6 added, 7 deleted, 2 changed) OCL=17447 CL=17461
parent
a6b546fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
conn.go
src/lib/http/conn.go
+2
-9
io.go
src/lib/io.go
+6
-0
No files found.
src/lib/http/conn.go
View file @
7c7a525d
...
...
@@ -11,16 +11,9 @@ import (
"os"
)
// Read/write/close interface.
type
RWC
interface
{
Read
(
p
*
[]
byte
)
(
n
int
,
err
*
os
.
Error
);
Write
(
p
*
[]
byte
)
(
n
int
,
err
*
os
.
Error
);
Close
()
*
os
.
Error
;
}
// Active HTTP connection (server side).
export
type
Conn
struct
{
rwc
RWC
;
rwc
io
.
ReadWriteClose
;
br
*
bufio
.
BufRead
;
bw
*
bufio
.
BufWrite
;
close
bool
;
...
...
@@ -28,7 +21,7 @@ export type Conn struct {
}
// Create new connection from rwc.
export
func
NewConn
(
rwc
RWC
)
(
c
*
Conn
,
err
*
os
.
Error
)
{
export
func
NewConn
(
rwc
io
.
ReadWriteClose
)
(
c
*
Conn
,
err
*
os
.
Error
)
{
c
=
new
(
Conn
);
c
.
rwc
=
rwc
;
if
c
.
br
,
err
=
bufio
.
NewBufRead
(
rwc
);
err
!=
nil
{
...
...
src/lib/io.go
View file @
7c7a525d
...
...
@@ -19,6 +19,12 @@ export type ReadWrite interface {
Write
(
p
*
[]
byte
)
(
n
int
,
err
*
os
.
Error
);
}
export
type
ReadWriteClose
interface
{
Read
(
p
*
[]
byte
)
(
n
int
,
err
*
os
.
Error
);
Write
(
p
*
[]
byte
)
(
n
int
,
err
*
os
.
Error
);
Close
()
*
os
.
Error
;
}
export
func
WriteString
(
w
Write
,
s
string
)
(
n
int
,
err
*
os
.
Error
)
{
b
:=
new
([]
byte
,
len
(
s
)
+
1
);
if
!
syscall
.
StringToBytes
(
b
,
s
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment