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
4f64ecfd
Commit
4f64ecfd
authored
Jul 29, 2010
by
Fazlul Shahriar
Committed by
Russ Cox
Jul 29, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add https client support
Fixes #851. R=rsc CC=golang-dev
https://golang.org/cl/1729052
parent
518df525
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
handshake_client.go
src/pkg/crypto/tls/handshake_client.go
+1
-1
client.go
src/pkg/http/client.go
+11
-4
No files found.
src/pkg/crypto/tls/handshake_client.go
View file @
4f64ecfd
...
@@ -93,7 +93,7 @@ func (c *Conn) clientHandshake() os.Error {
...
@@ -93,7 +93,7 @@ func (c *Conn) clientHandshake() os.Error {
}
}
// TODO(rsc): Find certificates for OS X 10.6.
// TODO(rsc): Find certificates for OS X 10.6.
if
false
&&
c
.
config
.
RootCAs
!=
nil
{
if
c
.
config
.
RootCAs
!=
nil
{
root
:=
c
.
config
.
RootCAs
.
FindParent
(
certs
[
len
(
certs
)
-
1
])
root
:=
c
.
config
.
RootCAs
.
FindParent
(
certs
[
len
(
certs
)
-
1
])
if
root
==
nil
{
if
root
==
nil
{
return
c
.
sendAlert
(
alertBadCertificate
)
return
c
.
sendAlert
(
alertBadCertificate
)
...
...
src/pkg/http/client.go
View file @
4f64ecfd
...
@@ -8,6 +8,7 @@ package http
...
@@ -8,6 +8,7 @@ package http
import
(
import
(
"bufio"
"bufio"
"crypto/tls"
"encoding/base64"
"encoding/base64"
"fmt"
"fmt"
"io"
"io"
...
@@ -21,7 +22,7 @@ import (
...
@@ -21,7 +22,7 @@ import (
func
hasPort
(
s
string
)
bool
{
return
strings
.
LastIndex
(
s
,
":"
)
>
strings
.
LastIndex
(
s
,
"]"
)
}
func
hasPort
(
s
string
)
bool
{
return
strings
.
LastIndex
(
s
,
":"
)
>
strings
.
LastIndex
(
s
,
"]"
)
}
// Used in Send to implement io.ReadCloser by bundling together the
// Used in Send to implement io.ReadCloser by bundling together the
//
io.Buf
Reader through which we read the response, and the underlying
//
bufio.
Reader through which we read the response, and the underlying
// network connection.
// network connection.
type
readClose
struct
{
type
readClose
struct
{
io
.
Reader
io
.
Reader
...
@@ -34,13 +35,13 @@ type readClose struct {
...
@@ -34,13 +35,13 @@ type readClose struct {
// send() method is nonpublic because, when we refactor the code for persistent
// send() method is nonpublic because, when we refactor the code for persistent
// connections, it may no longer make sense to have a method with this signature.
// connections, it may no longer make sense to have a method with this signature.
func
send
(
req
*
Request
)
(
resp
*
Response
,
err
os
.
Error
)
{
func
send
(
req
*
Request
)
(
resp
*
Response
,
err
os
.
Error
)
{
if
req
.
URL
.
Scheme
!=
"http"
{
if
req
.
URL
.
Scheme
!=
"http"
&&
req
.
URL
.
Scheme
!=
"https"
{
return
nil
,
&
badStringError
{
"unsupported protocol scheme"
,
req
.
URL
.
Scheme
}
return
nil
,
&
badStringError
{
"unsupported protocol scheme"
,
req
.
URL
.
Scheme
}
}
}
addr
:=
req
.
URL
.
Host
addr
:=
req
.
URL
.
Host
if
!
hasPort
(
addr
)
{
if
!
hasPort
(
addr
)
{
addr
+=
":
http"
addr
+=
":
"
+
req
.
URL
.
Scheme
}
}
info
:=
req
.
URL
.
Userinfo
info
:=
req
.
URL
.
Userinfo
if
len
(
info
)
>
0
{
if
len
(
info
)
>
0
{
...
@@ -52,7 +53,13 @@ func send(req *Request) (resp *Response, err os.Error) {
...
@@ -52,7 +53,13 @@ func send(req *Request) (resp *Response, err os.Error) {
}
}
req
.
Header
[
"Authorization"
]
=
"Basic "
+
string
(
encoded
)
req
.
Header
[
"Authorization"
]
=
"Basic "
+
string
(
encoded
)
}
}
conn
,
err
:=
net
.
Dial
(
"tcp"
,
""
,
addr
)
var
conn
io
.
ReadWriteCloser
if
req
.
URL
.
Scheme
==
"http"
{
conn
,
err
=
net
.
Dial
(
"tcp"
,
""
,
addr
)
}
else
{
// https
conn
,
err
=
tls
.
Dial
(
"tcp"
,
""
,
addr
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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