patched MIMEDocument>>contentType:content:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

patched MIMEDocument>>contentType:content:

Sebastian Sastre-2
Hi there,
in order to be able to load SIXX 0.95 from universal installer I've needed to
unelegantly patch it (a pharo 413) to:

contentType: aString  content: content
        "create a MIMEObject with the given content-type and content"
        "MIMEObject contentType: 'text/plain' content: 'This is a test'"
       
        | ans idx |
        ans := self new.
        ans privateContent: content.

        "parse the content-type"
        (aString isNil or: [
                idx := aString asString indexOf: $/.
                idx = 0])
        ifTrue: [
                ans type: (MIMEType main: 'application' sub: 'octet-stream')]
        ifFalse: [
                ans type: (MIMEType main: (aString asString copyFrom: 1 to:
idx-1) sub: (aString asString copyFrom: idx+1 to: aString asString size))].

        ^ans

sebastian


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: patched MIMEDocument>>contentType:content:

Stéphane Ducasse
Hi sebastian

do you mean that the content may not be a string and that converting  
it would be better?

Stef

> in order to be able to load SIXX 0.95 from universal installer I've  
> needed to
> unelegantly patch it (a pharo 413) to:
>
> contentType: aString  content: content
> "create a MIMEObject with the given content-type and content"
> "MIMEObject contentType: 'text/plain' content: 'This is a test'"
>
> | ans idx |
> ans := self new.
> ans privateContent: content.
>
> "parse the content-type"
> (aString isNil or: [
> idx := aString asString indexOf: $/.
> idx = 0])
> ifTrue: [
> ans type: (MIMEType main: 'application' sub: 'octet-stream')]
> ifFalse: [
> ans type: (MIMEType main: (aString asString copyFrom: 1 to:
> idx-1) sub: (aString asString copyFrom: idx+1 to: aString asString  
> size))].
>
> ^ans
>
> sebastian
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project