mirror of https://github.com/adamdruppe/arsd.git
bug in skipping footers - caused data error
This commit is contained in:
parent
4c178891de
commit
f9bc47b0df
64
http2.d
64
http2.d
|
@ -687,6 +687,11 @@ class HttpRequest {
|
|||
//goto done; // FIXME
|
||||
state = State.complete;
|
||||
|
||||
// skip the tailing chunk of headers
|
||||
// FIXME
|
||||
if(data.length == 5 && data == [48, 13, 10, 13, 10])
|
||||
a = data.length;
|
||||
|
||||
if(bodyReadingState.isGzipped || bodyReadingState.isDeflated) {
|
||||
auto n = uncompress.uncompress(responseData.content);
|
||||
n ~= uncompress.flush();
|
||||
|
@ -753,7 +758,12 @@ class HttpRequest {
|
|||
size_t bodyBytesSent;
|
||||
size_t bodyBytesReceived;
|
||||
|
||||
State state;
|
||||
State state_;
|
||||
State state() { return state_; }
|
||||
State state(State s) {
|
||||
assert(state_ != State.complete);
|
||||
return state_ = s;
|
||||
}
|
||||
/// Called when data is received. Check the state to see what data is available.
|
||||
void delegate(HttpRequest) onDataReceived;
|
||||
|
||||
|
@ -1034,13 +1044,23 @@ version(use_openssl) {
|
|||
int SSL_connect(SSL*);
|
||||
int SSL_write(SSL*, const void*, int);
|
||||
int SSL_read(SSL*, void*, int);
|
||||
int SSL_pending(const SSL*);
|
||||
void SSL_free(SSL*);
|
||||
void SSL_CTX_free(SSL_CTX*);
|
||||
|
||||
int SSL_pending(const SSL*);
|
||||
|
||||
void SSL_set_verify(SSL*, int, void*);
|
||||
enum SSL_VERIFY_NONE = 0;
|
||||
|
||||
SSL_METHOD* SSLv3_client_method();
|
||||
SSL_METHOD* TLS_client_method();
|
||||
SSL_METHOD* SSLv23_client_method();
|
||||
|
||||
void ERR_print_errors_fp(FILE*);
|
||||
}
|
||||
|
||||
import core.stdc.stdio;
|
||||
|
||||
shared static this() {
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_ciphers();
|
||||
|
@ -1054,11 +1074,13 @@ version(use_openssl) {
|
|||
class OpenSslSocket : Socket {
|
||||
private SSL* ssl;
|
||||
private SSL_CTX* ctx;
|
||||
private void initSsl() {
|
||||
ctx = SSL_CTX_new(SSLv3_client_method());
|
||||
private void initSsl(bool verifyPeer) {
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
assert(ctx !is null);
|
||||
|
||||
ssl = SSL_new(ctx);
|
||||
if(!verifyPeer)
|
||||
SSL_set_verify(ssl, SSL_VERIFY_NONE, null);
|
||||
SSL_set_fd(ssl, this.handle);
|
||||
}
|
||||
|
||||
|
@ -1069,33 +1091,55 @@ version(use_openssl) {
|
|||
@trusted
|
||||
override void connect(Address to) {
|
||||
super.connect(to);
|
||||
if(SSL_connect(ssl) == -1)
|
||||
if(SSL_connect(ssl) == -1) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
int i;
|
||||
printf("wtf\n");
|
||||
scanf("%d\n", i);
|
||||
throw new Exception("ssl connect");
|
||||
}
|
||||
}
|
||||
|
||||
@trusted
|
||||
override ptrdiff_t send(const(void)[] buf, SocketFlags flags) {
|
||||
return SSL_write(ssl, buf.ptr, cast(uint) buf.length);
|
||||
auto retval = SSL_write(ssl, buf.ptr, cast(uint) buf.length);
|
||||
if(retval == -1) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
int i;
|
||||
printf("wtf\n");
|
||||
scanf("%d\n", i);
|
||||
throw new Exception("ssl send");
|
||||
}
|
||||
return retval;
|
||||
|
||||
}
|
||||
override ptrdiff_t send(const(void)[] buf) {
|
||||
return send(buf, SocketFlags.NONE);
|
||||
}
|
||||
@trusted
|
||||
override ptrdiff_t receive(void[] buf, SocketFlags flags) {
|
||||
return SSL_read(ssl, buf.ptr, cast(int)buf.length);
|
||||
auto retval = SSL_read(ssl, buf.ptr, cast(int)buf.length);
|
||||
if(retval == -1) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
int i;
|
||||
printf("wtf\n");
|
||||
scanf("%d\n", i);
|
||||
throw new Exception("ssl send");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
override ptrdiff_t receive(void[] buf) {
|
||||
return receive(buf, SocketFlags.NONE);
|
||||
}
|
||||
|
||||
this(AddressFamily af, SocketType type = SocketType.STREAM) {
|
||||
this(AddressFamily af, SocketType type = SocketType.STREAM, bool verifyPeer = true) {
|
||||
super(af, type);
|
||||
initSsl();
|
||||
initSsl(verifyPeer);
|
||||
}
|
||||
|
||||
this(socket_t sock, AddressFamily af) {
|
||||
super(sock, af);
|
||||
initSsl();
|
||||
initSsl(true);
|
||||
}
|
||||
|
||||
~this() {
|
||||
|
|
Loading…
Reference in New Issue