Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Volguus
Mar 3, 2009
Powershell is just wrong here. "content-type: application/json;charset=UTF-8" is a correct content-type header value.

Adbot
ADBOT LOVES YOU

Volguus
Mar 3, 2009
On the second thought, wait a minute. A JSON needs to have the charset specified because JSON is an idiotic format. An XML specifies its own encoding via the declaration:

code:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
So, you don't have to set it in the header. Though, the client shouldn't yell, it should be fine, but yes it is a bit superfluous.

Volguus
Mar 3, 2009

sloshmonger posted:

I guess you could say I'm not a... Method Man

That would be a "methodic" or a "methodist".
I'd go with the religious one.

Volguus
Mar 3, 2009

Hammerite posted:

Being mistaken happens to the best of us.

Yes I think I would agree and generalise what you're saying as: it is useful to keep in mind the need to be aware whether you're testing for existence of files, directories, or both. One reason is to want to know whether a filesystem object is created and is specifically a directory, so (ignoring security for the moment) you would expect to be able to create things inside it. I'm more likely to be writing C# than Powershell code, and using Directory.Exists() or File.Exists(). But there too I might want to check both, to avoid leaving the silly edge case where I test whether a directory existed, and it didn't, but the program will still blow up when I try to create the directory because a file existed with that name.

The program can blow up when trying to create a file or directory for a ton of reasons, some of them related to security, some of them not (write to a file and the disk is full, for example).

You should always expect that to happen when doing I/O and take precautions ( at least a try/catch with some readable message).

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply