void HandleDecryptionHeader(STREAM *S, const char *Header, const char *Key) { const char *ptr; char *Tempstr=NULL; ptr=Header; if (strncmp(ptr,"ENCR ",5)==0) ptr+=5; Tempstr=MCopyStr(Tempstr,ptr," key='",Key,"'",NULL); fprintf(stderr,"SASDP: [%s]\n",Tempstr); STREAMAddStandardDataProcessor(S,"crypto","",Tempstr); DestroyString(Tempstr); }
void HTTPServerSendFile(STREAM *S, HTTPSession *Session, char *Path, ListNode *Vars, int Flags) { STREAM *Doc; HTTPSession *Response; char *Buffer=NULL, *Tempstr=NULL; int ICYInterval=4096000; Doc=STREAMOpenFile(Path, SF_RDONLY); if (! Doc) HTTPServerSendHTML(S, Session, "403 Forbidden","You don't have permission for that."); else { if (Session) { LogToFile(Settings.LogPath,"%s@%s (%s) downloading %s (%s bytes)",Session->UserName,Session->ClientHost,Session->ClientIP,Path,GetVar(Vars,"FileSize")); } Response=FileSendCreateSession(Path, Session, Vars, ICYInterval); MediaReadDetails(Doc,Vars); HTTPServerFormatExtraHeaders(Response,Vars); HTTPServerSendHeaders(S, Response, Flags); if (Response->Flags & SESSION_ENCODE_GZIP) { STREAMAddStandardDataProcessor(S,"compression","gzip","CompressionLevel=1"); } if (Flags & HEADERS_SENDFILE) { if (Session->Flags & SESSION_ICECAST) IcecastSendData(Doc, S, ICYInterval); else STREAMSendFile(Doc, S, 0, SENDFILE_KERNEL | SENDFILE_LOOP); } /* If HTTPServerSendHeaders set SESSION_REUSE then set that in the Session object if (Response->Flags & SESSION_REUSE) Session->Flags |= SESSION_REUSE; else Session->Flags &= ~SESSION_REUSE; */ STREAMClose(Doc); HTTPSessionDestroy(Response); } DestroyString(Buffer); DestroyString(Tempstr); }
int AddEncryptionHeader(STREAM *S, int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt) { char *EncryptArgs=NULL; char *Tempstr=NULL; int result=FALSE; EncryptArgs=FormatEncryptArgs(EncryptArgs,Flags, Cipher, Key, InitVector,Salt); if (STREAMAddStandardDataProcessor(S,"Crypto",Cipher,EncryptArgs)) { EncryptArgs=FormatEncryptArgs(EncryptArgs,Flags, Cipher, "", InitVector,Salt); Tempstr=FormatStr(Tempstr,"ENCR %s\n",EncryptArgs); STREAMWriteLine(Tempstr,S); result=TRUE; } DestroyString(Tempstr); DestroyString(EncryptArgs); return(result); }
STREAM *HTTPTransact(HTTPInfoStruct *Info) { int result=HTTP_NOCONNECT; while (1) { if (! Info->S) Info->S=HTTPConnect(Info); else if (! (Info->State & HTTP_HEADERS_SENT)) HTTPSendHeaders(Info->S,Info); if (Info->S && STREAMIsConnected(Info->S)) { Info->ResponseCode=CopyStr(Info->ResponseCode,""); if (! (Info->State & HTTP_CLIENTDATA_SENT)) { //Set this even if no client data to send, so we no we've been //through here once Info->State |= HTTP_CLIENTDATA_SENT; if (StrLen(Info->PostData)) { STREAMWriteLine(Info->PostData,Info->S); if (Info->Flags & HTTP_DEBUG) fprintf(stderr,"\n%s\n",Info->PostData); } else { if (strcasecmp(Info->Method,"POST")==0) break; if (strcasecmp(Info->Method,"PUT")==0) break; } } //Must clear this once the headers and clientdata sent Info->State=0; HTTPReadHeaders(Info->S,Info); result=HTTPProcessResponse(Info); STREAMSetValue(Info->S,"HTTP:URL",Info->Doc); if (Info->Flags & HTTP_CHUNKED) HTTPAddChunkedProcessor(Info->S); if (Info->Flags & HTTP_GZIP) { STREAMAddStandardDataProcessor(Info->S,"compression","gzip",""); } else if (Info->Flags & HTTP_DEFLATE) STREAMAddStandardDataProcessor(Info->S,"compression","zlib",""); if (result == HTTP_OKAY) break; if (result == HTTP_NOTFOUND) break; if (result == HTTP_NOTMODIFIED) break; if (result == HTTP_ERROR) break; if (result == HTTP_CIRCULAR_REDIRECTS) break; if (result == HTTP_AUTH_BASIC) { if ( (! Info->Authorization) || ( (Info->Authorization->Flags & HTTP_SENT_AUTH) || (! Info->Authorization->Logon) || (StrLen(Info->Authorization->Logon)==0) ) ) { if (result == HTTP_AUTH_BASIC) break; if (result == HTTP_AUTH_DIGEST) break; } } if ( (result == HTTP_PROXY_AUTH) && ( (Info->ProxyAuthorization->Flags & HTTP_SENT_AUTH) || (! Info->ProxyAuthorization->Logon) || (StrLen(Info->ProxyAuthorization->Logon)==0) ) ) { break; } STREAMClose(Info->S); Info->S=NULL; } else break; } return(Info->S); }